Repository navigation
Compute signatures of dependent files in parallel on incremental rebuilds #64659
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
Open
Gadzhi Gadzhiev (resure)
wants to merge
6
commits into
microsoft:main
Choose a base branch
from
resure:fix/parallel-signature-computation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+219
−53
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
49616b6
Compute signatures of dependent files in parallel
resure a975ba5
Bound signature computation for changed files too
resure 7f0e5e1
Limit signature concurrency in the work group
resure 8eb7a75
Keep a changed default library file out of the affected set
resure 4d50c86
Merge remote-tracking branch 'origin/main' into fix/parallel-signatur…
resure d0741eb
Drop the scenario and benchmark that existing tests already cover
resure File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package core_test | ||
|
|
||
| import ( | ||
| "runtime" | ||
| "sync" | ||
| "sync/atomic" | ||
| "testing" | ||
|
|
||
| "github.com/microsoft/TypeScript/tsc/internal/core" | ||
| "gotest.tools/v3/assert" | ||
| ) | ||
|
|
||
| func TestWorkGroupConcurrencyLimit(t *testing.T) { | ||
| t.Parallel() | ||
| const limit = 3 | ||
| const depth = 2 | ||
| const children = 4 | ||
| wg := core.NewWorkGroup(limit) | ||
| var running, maxRunning, completed atomic.Int32 | ||
| var allRootsRunning sync.WaitGroup | ||
| allRootsRunning.Add(limit) | ||
| var queue func(remaining int) | ||
| queue = func(remaining int) { | ||
| wg.Queue(func() { | ||
| now := running.Add(1) | ||
| for { | ||
| seen := maxRunning.Load() | ||
| if now <= seen || maxRunning.CompareAndSwap(seen, now) { | ||
| break | ||
| } | ||
| } | ||
| if remaining == depth { | ||
| allRootsRunning.Done() | ||
| allRootsRunning.Wait() | ||
| } | ||
| if remaining > 0 { | ||
| for range children { | ||
| queue(remaining - 1) | ||
| } | ||
| } | ||
| runtime.Gosched() | ||
| running.Add(-1) | ||
| completed.Add(1) | ||
| }) | ||
| } | ||
| for range limit { | ||
| queue(depth) | ||
| } | ||
| wg.RunAndWait() | ||
| assert.Equal(t, completed.Load(), int32(limit*(1+children+children*children))) | ||
| assert.Equal(t, maxRunning.Load(), int32(limit)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is all of this change needed? Why can't we just do a parallel work group and then use a bounded semaphore where needed?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because "where needed" depends on the resource you're trying to limit based on - when that resource is "system cores", "where needed" is everywhere the workgroup is used, so for a case like this one, which reuses the same workgroup at multiple task levels, requires threading a semaphore to a bunch of places, alongside the workgroup itself.
It's just nicer to build the concurrency limiter into the concurrency abstraction itself, imo, and the existing
singleThreadedparameter was already a concurrency limit - just not as configurable as needed.