-
Notifications
You must be signed in to change notification settings - Fork 3k
do not release weak refs twice #19149
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
Draft
DonIsaac
wants to merge
11
commits into
main
Choose a base branch
from
don/experiment/no-release-weakref-twice
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.
Draft
Conversation
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
Updated 3:58 PM PT - Apr 22nd, 2025
✅ @DonIsaac, your commit 27b8a3afd473357a9f7191f93fc7a08128fd44ba passed in 🧪 try this PR locally: bunx bun-pr 19149 |
edit: no noticeable difference in async and websocket benchmarks. |
DonIsaac
commented
Apr 21, 2025
@@ -3948,6 +3948,7 @@ void GlobalObject::drainMicrotasks() | |||
if (auto nextTickQueue = this->m_nextTickQueue.get()) { | |||
Bun::JSNextTickQueue* queue = jsCast<Bun::JSNextTickQueue*>(nextTickQueue); | |||
queue->drain(vm, this); | |||
vm.finalizeSynchronousJSExecution(); |
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.
note: also called by vm.drainMicrotasks()
…release-weakref-twice
…oven-sh/bun into don/experiment/no-release-weakref-twice
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.
What does this PR do?
Makes several improvements and fixes to microtask-related code
releaseWeakRefs
before draining microtask queue. It's already done afterwards.JSGlobalObject.reload()
now drainsnextTick
queue as well as microtask queuenextTick
queue when there's a pending termination exceptionJSC__JSGlobalObject__drainMicrotasks
will already callfinalizeSynchronousJSExecution
, meaning we incrementm_currentWeakRefVersion
twice (once before draining, once after draining).While
finalizeSynchronousJSExecution
is cheap, It is defined in C++ code, making it opaque to the Zig compiler and preventing inlining optimizations. Draining microtasks is a critical perf path, and avoiding this extra function call may lead to perf gains.How did you verify your code works?
let's see what happens in CI