feat(allocator): FixedSizeAllocator store flag recording if owned by both Rust and JS#12381
Merged
graphite-app[bot] merged 1 commit intomainfrom Jul 18, 2025
Conversation
This was referenced Jul 18, 2025
Member
Author
This was referenced Jul 18, 2025
Merged
CodSpeed Instrumentation Performance ReportMerging #12381 will not alter performanceComparing Summary
|
This was referenced Jul 18, 2025
Contributor
Merge activity
|
…y both Rust and JS (#12381) Add a field `is_double_owned` to `FixedSizeAllocatorMetadata`. This field tracks ownership of the allocator/buffer. It's `true` if both Rust and JS currently hold a reference to the memory, or `false` if only one does. `Drop` impl for `FixedSizeAllocator` checks the value of this field and only frees the memory if JS doesn't also hold a reference. At present, `is_double_owned` is always `false`, because we're not transferring buffers over to JS yet. But it'll come into play in later PR. At that point the finalizer which runs when JS garbage collector collects the buffer will also update `is_double_owned`, and free the memory if Rust already dropped the `FixedSizeAllocator`, so JS is the only remaining owner.
43b0114 to
bc0fbe5
Compare
90fb884 to
b0db2d7
Compare
Base automatically changed from
07-16-feat_allocator_allocatorpool_store_ids_in_allocator_s
to
main
July 18, 2025 09:11
graphite-app bot
pushed a commit
that referenced
this pull request
Jul 21, 2025
`AtomicBool::store` does the same as `fetch_and(false)` / `fetch_or(true)`, is simpler, and possibly a little bit cheaper. Not sure why I didn't use it in the first place in #12381!
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.

Add a field
is_double_ownedtoFixedSizeAllocatorMetadata. This field tracks ownership of the allocator/buffer. It'strueif both Rust and JS currently hold a reference to the memory, orfalseif only one does.Dropimpl forFixedSizeAllocatorchecks the value of this field and only frees the memory if JS doesn't also hold a reference.At present,
is_double_ownedis alwaysfalse, because we're not transferring buffers over to JS yet. But it'll come into play in later PR. At that point the finalizer which runs when JS garbage collector collects the buffer will also updateis_double_owned, and free the memory if Rust already dropped theFixedSizeAllocator, so JS is the only remaining owner.