-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use TaskGroups instead of array of tasks #7
base: main
Are you sure you want to change the base?
Conversation
Instead of sorting does it make sense to do something like: var results = Array<T?>(repeating: nil, count: self.count)
...
for try await result in group {
results[result.offset] = result.value
}
return results as! [T] |
@AndrewBarba I’d say yes. And it’s probably faster too. I’ll push your alternative. |
I’m not sure we gain a lot. We’d have to actually measure this solution and the one in the previous commit.
Done. However, |
I don't think it is necessary to have |
@tachyonics You’re not wrong. I have pushed your method. |
Fully support these changes. Not only will it make the functions more performant, but it will ensure each function participates in |
Rationale for this comes from this thread https://forums.swift.org/t/taskgroup-vs-an-array-of-tasks/53931
Apparently launching a lot of Tasks just like that is not very good, and we should use task groups instead.
I did not test the performance implication of this change, though. Maybe it’s actually worse because of the additional sort needed. In theory it should be better though.