Repository navigation
Conversation
AbortSignal.any() follows its sources as soon as it creates a composite, so aborting a source synchronously aborts every composite that follows it. The aborted and reason getters and throwIfAborted() still walked the composite's sources on every call and dereferenced the WeakRef of each one, which is expensive because WeakRef.prototype.deref() adds its target to the kept objects of the current job. That walk can no longer find an aborted source of a composite that isn't aborted itself, so remove it. throwIfAborted() on a composite with two sources becomes about 17 times faster, the same as on a plain signal. Add a benchmark for throwIfAborted() on plain, timeout, composite and mixed signals. Assisted-by: claude:opus-5.5 Signed-off-by: Robert Nagy <ronagy@icloud.com>
Collaborator
|
Review requested:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the removal of redundant composite AbortSignal source checks.
No open issues 🎉
What changed in this PR
Builds on the eager abort propagation introduced in #66014 to remove redundant source checks when reading composite AbortSignal state.
Changes:
- Removes
refreshCompositeSignal()and its calls from accessors,throwIfAborted(), and composite construction. - Adds a
throwIfAborted()benchmark covering controller, timeout, composite, and mixed signals.
| File | Description |
|---|---|
lib/internal/abort_controller.js |
Removes source refreshes and documents why composite abort state stays current. |
benchmark/abort_controller/abort-signal-throw-if-aborted.js |
Adds performance coverage for repeated non-aborted signal checks. |
Review effort: Balanced
ronag
marked this pull request as ready for review
November 17, 2026 14:11
panva
approved these changes
Nov 17, 2026
Collaborator
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67543 +/- ##
==========================================
- Coverage 90.67% 90.67% -0.01%
==========================================
Files 800 800
Lines 280489 280912 +423
Branches 54166 54280 +114
==========================================
+ Hits 254336 254716 +380
- Misses 16277 16296 +19
- Partials 9876 9900 +24
🚀 New features to boost your workflow:
|
Contributor
Failed to start CIFull Auto Start CI output |
gurgunday
approved these changes
Nov 17, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Since #66014,
AbortSignal.any()follows its sources as soon as it creates a composite, so aborting a source aborts every composite that follows it right away. Theabortedandreasongetters andthrowIfAborted()still walked the composite's sources on every call. ProfilingthrowIfAborted()on a two-source composite put 91% of the time in that walk, most of it inWeakRef.prototype.deref(), which adds its target to the kept objects of the current job.That walk can't find anything anymore: a composite is always aborted by the time one of its sources is. So this removes
refreshCompositeSignal()and adds a benchmark forthrowIfAborted().test-abortsignal-any-source-gcalready checks each accessor after a source has been aborted and collected.node benchmark/abort_controller/abort-signal-throw-if-aborted.js, release builds of main and this branch, Linux x64, 30 interleaved runs per binary:The
abortedgetter gets the same speedup. In the existingabort_controllerbenchmarks,anywithlistenis 7% faster andaddAbortListeneris 2-3.5% slower. Its optimized code is the same apart from the removed check (same inlining, no deopts), so I think that one is code layout, but it shows up consistently.