-
Couldn't load subscription status.
- Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresperformancestandard libraryArea: Standard library umbrellaArea: Standard library umbrellaswift 5.5
Description
| Previous ID | SR-15785 |
| Radar | rdar://problem/88219931 |
| Original Reporter | @jshier |
| Type | Bug |
| Status | Resolved |
| Resolution | Done |
Environment
macOS 12.2, Xcode 13.2.1 and 13.3, 2020 i9 iMac, M1 Max MacBook Pro.
Additional Detail from JIRA
| Votes | 0 |
| Component/s | swift |
| Labels | Bug, Concurrency, Performance |
| Assignee | @Catfish-Man |
| Priority | Medium |
md5: cd628c72dea7e813640f5edee1597d34
Issue Description:
Attempting to enqueue many children, while quite easy with TaskGroup, is more than linear when you get into the tens of thousands. As a fundamental concurrency primitive, it would be beneficial if this performance could be improved.
Additionally, addTask seems to block the execution of children, letting memory balloon as the children are enqueued but aren't be executed.
Here's a simple example:
@main
struct ConcurrencyTest {
static func main() async {
let start = CFAbsoluteTimeGetCurrent()
@Sendable
func doNothing() {}
await withTaskGroup(of: Void.self) { group in
for _ in 0..<100_000 {
group.addTask(operation: doNothing)
}
await group.waitForAll()
}
print(CFAbsoluteTimeGetCurrent() - start)
}
}This code takes 35.6s to execute on a 2020 i9 iMac and, shockingly, 89s on an M1 Max MacBook Pro.
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresperformancestandard libraryArea: Standard library umbrellaArea: Standard library umbrellaswift 5.5