[alloc+atomic] Make ghost_tree_bstack_allocator thread-safe with BSTACK_FEATURE_ATOMIC#14
Merged
Conversation
…STACK_FEATURE_ATOMIC`
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the C implementation of ghost_tree_bstack_allocator_t to support safe cross-thread use when compiled with -DBSTACK_FEATURE_ATOMIC, matching the intent of the Rust-side change in PR #13. It introduces an in-memory mutex to serialize AVL-tree mutations and uses bstack_try_discard / bstack_try_extend_zeros for atomic tail operations, plus adds concurrency-focused test coverage and CI wiring.
Changes:
- Add an optional (feature-gated) in-memory mutex to
ghost_tree_bstack_allocator_tand use it to serialize AVL mutations underBSTACK_FEATURE_ATOMIC. - Switch tail resize/free paths to
bstack_try_extend_zeros/bstack_try_discardunderBSTACK_FEATURE_ATOMIC. - Add concurrent stress tests for alloc/dealloc/realloc/bulk paths and run them in CI via a new
make test-ghost-tree-atomictarget.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
c/test_ghost_tree.c |
Adds concurrent allocator stress tests gated by BSTACK_FEATURE_ATOMIC. |
c/Makefile |
Adds test-ghost-tree-atomic target to build/run ghost-tree tests against the SET+ATOMIC alloc library. |
c/bstack_alloc.h |
Documents thread-safety behavior and adds a feature-gated lock field to the allocator struct; updates magic string comment. |
c/bstack_alloc.c |
Implements mutex init/destroy helpers and makes ghost-tree allocator operations thread-safe under BSTACK_FEATURE_ATOMIC (including atomic tail paths). |
.github/workflows/cci.yml |
Runs the new atomic ghost-tree test target in CI (non-Windows). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Description: This is the C mirror of #13
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
C Only: Yes
Fuzz: Yes
Safety Review: Needed: Crash Safety, Invariants, Thread Safety