Repository navigation
Make memory accounting lock-free - #12
Merged
Merged
Conversation
alexy
force-pushed
the
work/lock-free-memory
branch
from
September 20, 2026 09:21
31d4a7b to
5db3b08
Compare
docs/lock-free.md, L1 to L4. live_bytes and peak_bytes are atomics admitted by the same compare-exchange as work units; only cancellation wakers keep the mutex. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
alexy
force-pushed
the
work/lock-free-memory
branch
from
September 20, 2026 10:11
5db3b08 to
8fca3ee
Compare
alexy
added a commit
that referenced
this pull request
Sep 20, 2026
Documentation only. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
alexy
added a commit
that referenced
this pull request
Sep 20, 2026
The recipe's check that no code changed on main after #12 now fails: four commits touch crates/ since 0995224. The pin keeps that commit and loses the label "main". Adds an input on the fourth-pin question and offers to build the historical pins off quegee's critical path. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
alexy
added a commit
that referenced
this pull request
Sep 20, 2026
Confirms the four pins form a linear ancestor chain, that cee2693 is still the newest code-changing commit on main, and that the harness and Turso pins match. Notes that main against #12 is a difference rather than a delta, since five commits touch crates/ between them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
alexy
added a commit
that referenced
this pull request
Sep 20, 2026
…, sweep is sequential-only Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sak2FQcdgs5pkL2ruKrSUZ
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.
Implements
docs/lock-free.mdas designed; that file now records the outcome.ExecutionContextholds accounted bytes and their high-water mark as atomics and admits a memory charge through the same compare-exchange loop as a work charge, so a byte limit stays exact under concurrent charges. Releases are onefetch_sub. Only the cancellation wakers stay behind the mutex.Why: the reference Cypher executor charges the logical bytes of every copied value, so a streaming query charges memory once or more per element. The lock was about 11% of the profile of the full-path
reducequery.Behaviour that changes
usage()reads its three figures in sequence, not as one snapshot. It reportsmax(peak, live), sopeak_bytes >= live_bytesfor every reader; read after execution for exact totals.Tests
tests/contracts/memory.rs: sixteen threads racing for a limit that fits exactly fifty chunks admit exactly fifty, over fifty rounds; cross-thread drops returnlive_bytesto zero; the peak is a true maximum, unmoved by refusals, never observed below live by a racing reader; overflow is a budget failure. Not model-checked withloom. 1,297 tests pass acrossgrust-core,grust-cypher,grust-memory,grust-turso,grust-algorithms,grust-algorithm-proceduresandgrust-datafusion.Measured (one laptop, release, whole-process wall time, best of seven)
reducefoldreducefoldUNWINDaggregateThe lock-free figure was measured before and after the mutex figure and reproduced. Paths that charge memory rarely do not move, so the regression the plan guarded against did not appear here. The paired benchmark-harness run has not happened and these figures are not a substitute for it.
🤖 Generated with Claude Code