5.6: Fix SR-15785 by adding a cached reference to the last linked list node, avoiding n^2 append scaling #41192
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation: Adding children to a TaskGroup is currently n^2, which is causing severe performance issues for users of Swift Concurrency.
Scope: This change improves the performance of adding 50,000 children to a group from 10-15 seconds to less than 0.2 seconds. It costs one word of memory per child.
Radar/SR Issue: SR-15785
Risk: If I got the change wrong we could potentially see crashes or other misbehavior when using TaskGroups
Testing: Test suite passes, community provided benchmark shows expected improvement
Reviewer: @DougGregor (I think you're the Concurrency code owner? CODE_OWNERS doesn't list it)
Original PR: #41165