Skip to content

[alloc+atomic] Make GhostTreeBStackAllocator Sync under the atomic feature flag#13

Merged
williamwutq merged 13 commits into
masterfrom
atomic
Jun 5, 2026
Merged

[alloc+atomic] Make GhostTreeBStackAllocator Sync under the atomic feature flag#13
williamwutq merged 13 commits into
masterfrom
atomic

Conversation

@williamwutq

Copy link
Copy Markdown
Owner

Description: Under the flag atomic, making GhostTreeBStackAllocator (Rust) operations atomic and safe across threads with a mutex and bstack atomic methods such as try_extend_zeros and try_discard, implementing the rust Sync trait.

Important Feature: No
Type: Allocator - Optimization; Allocator - Concurrent
Magic Number: ALGT
Bulk: No
Tests: Included
Feature Flags: alloc + set
Breaking change: No
New Types: None
Rust Only: Yes
Fuzz: Yes
Safety Review: Needed: Crash Safety, Invariants, Thread Safety

@williamwutq williamwutq self-assigned this Jun 4, 2026
@williamwutq williamwutq changed the title Atomic [alloc+atomic] Make GhostTreeBStackAllocator Sync under the atomic feature flag Jun 4, 2026
@williamwutq williamwutq marked this pull request as ready for review June 5, 2026 03:50

@williamwutq williamwutq left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates GhostTreeBstackAllocator to support safe concurrent &self usage under the atomic feature flag, making the allocator Sync by serializing AVL free-tree mutations with an internal mutex and using BStack’s atomic tail operations (try_extend_zeros, try_discard) where possible.

Changes:

  • Add a Mutex<()> field behind cfg(feature = "atomic") and remove the !Sync marker in that configuration.
  • Wrap AVL free-tree remove/insert operations in the mutex and restructure alloc/alloc_bulk to release the lock before potentially expensive extend/zero calls.
  • Use try_discard / try_extend_zeros as lock-free fast paths for tail shrink/grow in realloc, dealloc, and dealloc_bulk, plus update the thread-safety docs and doctest gating accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/alloc/ghost_tree.rs
@williamwutq williamwutq merged commit c6fe9aa into master Jun 5, 2026
16 checks passed
@williamwutq williamwutq deleted the atomic branch June 5, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants