Skip to content

[alloc+atomic] Make ghost_tree_bstack_allocator thread-safe with BSTACK_FEATURE_ATOMIC#14

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

[alloc+atomic] Make ghost_tree_bstack_allocator thread-safe with BSTACK_FEATURE_ATOMIC#14
williamwutq merged 2 commits into
masterfrom
atomic

Conversation

@williamwutq

Copy link
Copy Markdown
Owner

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

@williamwutq williamwutq self-assigned this Jun 5, 2026
Comment thread c/test_ghost_tree.c Dismissed
Comment thread c/test_ghost_tree.c Dismissed

@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

@williamwutq williamwutq requested a review from Copilot June 5, 2026 06:44
@williamwutq williamwutq marked this pull request as ready for review June 5, 2026 06:49

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 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_t and use it to serialize AVL mutations under BSTACK_FEATURE_ATOMIC.
  • Switch tail resize/free paths to bstack_try_extend_zeros / bstack_try_discard under BSTACK_FEATURE_ATOMIC.
  • Add concurrent stress tests for alloc/dealloc/realloc/bulk paths and run them in CI via a new make test-ghost-tree-atomic target.

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.

@williamwutq williamwutq merged commit a8ae139 into master Jun 5, 2026
11 checks passed
@williamwutq williamwutq deleted the atomic branch June 5, 2026 06:50
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.

3 participants