[node-core-library] iterator weighting isn't fully respected by Async#forEachAsync
#4688
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.
Summary
Followup to #4672. This PR fixes 2 bugs that I found while trying to integrate this with our CI,
Before
After
(a,b,c all have operation weight 10)

Details
The existing
AsyncQueueManager
requires theforEachAsync
implementation to be reentrant and to have multiple waiting iterators. Moving to a weighted operation model requires theforEachAsync
to lock when pulling off an item from the iterator as we don't know the operation weight until after we pop the item. To correct this difference, I updatedAsyncQueueManager
to explicitly reassign operations when marking the operation as complete or after handling a remote executing operation.This may affect performance, but the critical zone that is now being locked should not affect performance. As seen in the graphs above, this does change the
REMOTE_EXECUTING
behavior a bit.How it was tested
I tested this using the cobuilds build-tests sandbox repo and a bunch of console logs. I changed the operation weights to equal the
-p
parameter which caused sequential timelines.I would appreciate additional testing/validation to make sure I'm on the right track 🙏
Impacted documentation