Skip to content

Contention and the shared file

Record metadata
title: Contention and the shared file
status: open
priority: 2
anchors: setup#1, setup#34, p45
needs: web
needs_owner: 

Question

When many writers share one medium, what makes them wait on one another? State the hardware case exactly (cores, cache lines, locks, the cost of keeping copies coherent), then ask which parts carry over to participants sharing a repository, and in which register.

Why it matters

The owner came to the article from work on reducing contention in a parallel decoder (setup#34), and reads its "congested central organ" through that (setup#1). The layout of this repository already leans on the comparison: one file per line, no shared index, a status page that is generated. The comparison should be earned or withdrawn.

Leads

Recollections of the session that opened this line, and two leads from the first pass (Anderson; the push protocol). None has been checked against a source: verify each or strike it. (The first pass took out false sharing and compare-and-swap.)

  • Read-copy-update as the counterpart of "Where it stands" being rewritten while others read it (unchecked; McKenney, perfbook ch. 9, not yet read).
  • Work stealing as scheduling without a central queue.
  • Load-linked/store-conditional, which can fail when another processor writes anywhere in the reserved block, as a closer model of a claim than compare-and-swap (unchecked: from recollection of the ARM and POWER manuals).
  • Read-copy-update; work stealing as scheduling without a central queue.
  • Anderson (1990) on backoff for spin locks, for the retry loop in claim (named only).
  • A merge conflict as the repository's counterpart of an invalidated cache line.

From a second model's advice on the setup prompt, forwarded by the owner (record). Unchecked, like the rest:

  • Keeping two observations is easier than merging two decisions: a layout that avoids conflicts does not thereby produce a synthesis.

Where it stands

Two first passes were made at the same time on different branches (claude/adoring-mccarthy-i38dvr and master), neither seeing the other's hold; they were joined when the branches were merged on 28 November. The first below is the branch's pass on Drepper and McKenney, with its reading; the second is master's pass on the coherence primer and Herlihy, which has had no reading yet. The doubled work is itself an instance of what the branch's reading observed: two refs taken for the medium.

The first pass (28 November) states the hardware account from Drepper (2007) and McKenney (perfbook, 2023): writes need exclusive ownership of a cache line, so writers to different data on one line still serialise ("false sharing", measured by Drepper at 390–1,147% overhead on four separate processors), and the remedies are to partition data by owner and to keep shared data read-mostly. Carried to the repository, the unit of coherence is not the file but the branch ref: git updates a ref only by a compare-and-swap against its old value, so every push invalidates every peer's view, and disjoint work must still rebase and retry. That is a model, not an identity, with its breaks stated.

A cold reading the same day confirmed the quotations and figures at their pages, and the compare-and-swap identity more strongly than the pass did (git's pack protocol states it for the receiving side). It corrected three things: Drepper's classes of variable are misreported, and his third remedy, padding, has a counterpart the pass ruled out (one ref per holder, joined by git push --atomic: a hypothesis); his own second measurement shows the penalty depends on the distance between caches, which the pass left out; and the merge evidence rests on one concurrent integration, not seven. It also observed that the medium is not one ref at all: master and the branch this line was written on had diverged, each with its own holds, so the model's premise of a single coherence unit fails in fact, and with it the exclusivity of a hold.

The first pass (28 November) gave the hardware account from the coherence primer (single-writer–multiple-reader and data-value invariants, block granularity, false sharing) and Herlihy (1991: compare-and-swap settles a choice among any number of writers, reads and writes alone cannot), and held it against claim and a two-clone experiment. Found: a hold here is a compare-and-swap on the branch tip with randomised backoff; one holder per line is a model of the single-writer invariant, enforced on taking and only cooperative on keeping; and the repository has false sharing at the level of the branch, since writers of disjoint files still compete for one tip. The one-file-per-line layout cures conflicts, not contention. The branch imposes a total order of all marks where a per-line order would do, as a snooping bus does. A lost race of claim leaves no trace in history, so the contention the comparison predicts cannot yet be measured. Not yet read: git's push protocol, Anderson on backoff, the primer on directories.

A cold reading of that second pass (28 November) found its quotations exact, and corrected three things. The refusal its experiment showed is the client's (fetch first, sent before any update); the server's compare-and-swap is a second layer, now observed with a packet trace (<old> <new> <ref>, refused with "is at … but expected …"), for git's own receive-pack but not for GitHub's. Compare-and-swap is the primitive but claim is not Herlihy's protocol: with one register shared by all decisions, a loser learns nothing about its line, must loop, and after six tries may decide nothing, so the hold is a model, not an identity. And the primer's own remedy for false sharing is sub-block coherence (per-line refs), not directories, which answer the total order instead. Rebases have risen with concurrency (12 of 177 commits after 16:00Z against 1 of 50 before), consistent with the prediction, not a test of it.

A third pass (28 November, 17:17–17:25Z) measured the distance: a refused push costs one round trip, about 0.27 s, the same as a fetch of one branch or of all eleven, so at this size branch count does not show on the wire. The window in which a claim can lose is about 2 s, half of it load_state(), and 84% of that is the cross-branch reading of holds (201 git subprocesses): seeing further lengthened the transaction. In the burst after a batch started (23–27 commits a minute) a 2 s window survives about 45% of the time, and two of the session's three claims that reached a push lost six times running, which suggests losses correlated over a burst longer than claim's backoff (a hypothesis). The "nine orders" in the table is a comparison of two figures, only one of them now measured.

A cold reading of the third pass (28 November, about 17:50–18:05Z) re-ran its measurements. The cost of a refusal (one round trip, about 0.3 s) and the dominance of the cross-branch reading in load_state() hold; at a lower load load_state() fell to 0.42 s and 126 subprocesses, so its cost does scale with live holds, and the window (about 1.35 s) is a function of load, not a fixed 2 s. The backoff bound (23.4 s) is exact. The pass's commit rates (114 in the hour; 23 and 27 a minute) could not be reproduced from any ref: by author time across all refs the peak minute is 19 and 17:20 is empty. And the rate a claim meets is that of its own ref, which history does not record, since bursts reach master through merged branches. Until claim records its attempts, the line's rates are reconstructions.

Threads

  • The hardware account, precise and short, with sources.
  • A table: mechanism in hardware; counterpart in a shared repository; identity, model or analogy; where it breaks.
  • The prediction (ref retries rise with live holds; path conflicts stay near zero). Half done: path overlap in merges measured; the reading found only one of the seven merges to be a concurrent integration (disjoint paths), so the evidence is one case. Remaining: count retries. They should be recorded per contribution (in the session's own journal entry, a per-thread counter), not in a shared file, which would make a hot line of its own.
  • The hot files: limits.conf (10 commits by noon of the first day), tools/swarm.py, AGENTS.md, sources/manifest.tsv. Are they read-mostly in fact (written by few, at rest times), or contended? Measure writers per file per hour.
  • Hand the article's own congestion (p45) back to the-congested-central-organ: the present-day sense in this pass is a later register, and should not be read into 1974.
  • Check the leads above: RCU and LL/SC as models, against perfbook ch. 9 and an architecture manual.
  • Padding the ref (from the reading): one ref per hold or per line, a push touching several made with --atomic, master a view assembled from them. Does it remove the false sharing, and what does it cost the reader (Drepper's objection to padding is footprint)? A hypothesis; try it on a scratch repository before proposing it.
  • The partition (from the reading): two branches each taken for the medium, with no traffic between them except a merge someone chooses to make. Hand to lines/medium-and-authority.md, whose business it is; here, only say what the model predicts of it (holds stop being exclusive; the failure is silent until a merge).
  • Distance: measure what a refused push actually costs here (seconds per retry). About 0.27 s per refusal, about 2 s per attempt (third pass, §§1–2).
  • The hardware side of the distance: a sourced latency for a compare-and-swap and for a cross-socket line transfer (Drepper's tables, or the primer), so that the table's "nine orders" compares two measured figures.
  • Shorten the window (third pass, §5): re-read only the claimed id across branches inside the retry loop; let backoff outlast a burst or stop early. A tools hold; try it, then re-time claim.
  • Are losses correlated over a burst (third pass, §4)? Needs per-attempt records with times from several sessions in one burst, not one session's recollection.
  • The hardware account, precise and short, with sources. (First pass, §§1–3.)
  • A table: mechanism in hardware; counterpart in a shared repository; identity, model or analogy; where it breaks. Partly done: first pass, §5, for coherence, compare-and-swap, backoff and false sharing. Remaining: the central bottleneck as distinct from false sharing; read-copy-update; work stealing; merge conflicts (true sharing) set beside push refusals (false sharing).
  • One prediction the comparison makes about this repository that its git history could confirm or refute. Partly done: the prediction is that refused pushes grow with the total push rate to the branch, not with demand for any one line (pass, §6); history cannot show it, because claim re-makes a refused commit (pass, §7). Remaining: a counter of refused pushes (a tools hold: claim and sync could append a line to a log, or brief could report retries), then the count against the number of live holds.
  • Check in git's documentation (gitprotocol-pack) and against GitHub that a push is refused by an old-value comparison on the ref. Observed for git 2.43's receive-pack over the file transport (the reading); the documentation and GitHub's server remain.
  • Sub-blocking (from the reading): per-line refs, or a ref for holds, as the primer's p. 199 remedy for false sharing. What does each extra ref cost every reader's fetch? Weigh with the padding thread above; they may be one thread.
  • Interconnect load (from the reading). Partly done: at 11 branches fetching all costs the same as fetching one (about 0.28 s, third pass §1); the growth is local instead, in across_branches, whose cost scales with hold files × branches (§2). Remaining: re-measure both when the branches number several dozen.
  • Record live holds per hour alongside rebased commits, so that the rise the reading counted (1 of 50 before 16:00Z, 12 of 177 after) can be set against load rather than the clock.
  • Per-line ordering, as directory protocols order per block: would holds on a ref of their own, or one ref per line, remove the false sharing? Read the primer's chapter 8 first; weigh it in medium-and-authority, which owns the medium.
  • The total order at one tip (pass, §8): is it a "central organ" in the article's sense? Ask in the-congested-central-organ.
  • Record each attempt of claim and sync (time, ref, outcome) in the session's own journal entry (reading of the third pass, §§5–6): without it no contention rate here can be measured, because the DAG does not say to which ref a commit was pushed, and rebases rewrite committer times. A tools hold.
  • claim sleeps once more after its sixth and last loss (up to 6.4 s for nothing). A slip for whoever holds tools.

Passes

2026-11-28 | claude-code | pass

Read for this pass: Drepper, What Every Programmer Should Know About Memory (2007), §3.3.4 and §6.4.1, pp. 26–27 and 65–67 (record); McKenney, Is Parallel Programming Hard, And, If So, What Can You Do About It? (edition v2023.06.11a), §3.2, §5.2 and ch. 8 (record); git's own documentation for git push and git update-ref at v2.43.0 (record); tools/swarm.py as it stands; and this repository's history on the medium up to 16:15 UTC. The forwarded advice (record, lines 191–199) supplied two of the leads this pass tests.

1. The hardware account (what the sources say). Data moves between memory and processors "in units of 'cache lines', which are power-of-two fixed-size aligned blocks of memory, usually ranging from 32 to 256 bytes"; to store a value a CPU "must also load the cacheline containing that variable into its cache, but must also ensure that no other CPU has a copy of that cacheline" (McKenney §3.2.1, p. 22). Drepper names the protocol that enforces this, MESI, after its four states, Modified, Exclusive, Shared, Invalid (p. 26). A write to a line that another processor holds requires "the infamous 'Request For Ownership' (RFO) operation", which invalidates the other copy, and "whenever such a message has to be sent things are going to be slow" (pp. 26–27). The cost is not in principle but in measure: on an eight-socket Xeon, a compare-and-swap costs 7 ns when the line is already local and 944.8 ns across the interconnect, about 1,984 clock periods (McKenney, Table 3.1, p. 23). Reading is cheap where writing is not: a variable "frequently read during a time interval during which it is never updated … can be replicated across all CPUs' caches" (p. 22).

False sharing is the case in which the ownership traffic is caused by the layout and not by the work. Drepper's test gives each of up to four threads its own counter to increment 500 million times; when the counters sit on separate lines the program "scales without penalty", and when they are moved onto one line the overhead is "390%, 734%, and 1,147% respectively" for two, three and four threads, because "all processors, except the one which has the cache line at any given moment, are delayed and cannot do anything" (pp. 65–66). The threads share no datum; they share only a unit of coherence. His remedy sorts variables by how they are written: those never written can be grouped and shared freely; those used by one thread only should be kept apart; only those "contested at times" need real synchronisation (p. 66). McKenney's general name for the second remedy is data ownership: parcel the data out "so that a given piece of data is accessed and modified by only one of the threads", which he calls "perhaps the most underappreciated synchronization mechanism in existence" (ch. 8, pp. 127–128). Its standard instance is the statistical counter: "a counter per thread … so that each thread updates its own counter", the total "read out by simply summing", which works because addition is commutative and associative (§5.2.1, p. 51).

2. The repository's unit of coherence (observed, then our reading). git updates a ref by compare-and-swap: git update-ref <ref> <newvalue> <oldvalue> stores the new value "after verifying that the current value of the matches " (git-update-ref documentation). A push follows the same rule at the remote: it "refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it", and the documentation's own word for the safe override is a "lease" on the ref "without explicitly locking it" (git-push, --force-with-lease). Source. tools/swarm.py (cmd_sync, cmd_claim) wraps this in a loop: fetch, rebase onto the medium (or merge if the rebase fails), push, and on rejection sleep 0.4 + random() × (attempt + 1) seconds, six attempts in all. Observed.

Our reading: the medium has one coherence unit, the branch ref, and it is far coarser than any datum held. Two sessions writing disjoint files (one line each, one hold file each, one journal entry each) still contend for that ref exactly as Drepper's threads contend for one cache line: whoever pushes second is refused, must fetch, rebase and try again, and during that round trip "cannot do anything" useful with the medium. The layout of the files already does what Drepper and McKenney recommend at the level of data: one file per line, one holder per line, one journal file per contribution (so the day's count in brief is a statistical counter, a sum over owners' entries, not a shared tally anyone increments), and a status page generated on read rather than kept. What the layout cannot partition is the ref. That is false sharing in the precise sense of the forwarded advice ("different data located in the same coherence block", line 195), at the granularity of a branch.

3. The correspondence, stated with its register.

hardware (source) repository (observed) register where it breaks
cache line, unit of coherence the branch ref on the medium model a cache line is fixed and small; the ref covers everything, and nothing can pad files onto separate refs without giving up a single medium
RFO invalidates other copies a push makes every peer's fetched view stale model invalidation is pushed to the other caches at once; a peer learns of staleness only at its own next checkpoint (fetch or a refused push)
compare-and-swap on a word update-ref with old value; push must fast-forward identity (the same operation: conditional store on equality of the old value) none in kind; the cost differs by about nine orders of magnitude
CAS retry loop with backoff sync/claim: rebase, push, randomised sleep, six tries identity of algorithm rebase rewrites the retrying participant's commits, which a hardware retry never does to data
false sharing (disjoint data, one line) disjoint files, one ref: rejected pushes that rebase cleanly model the hardware penalty is time only; here a clean rebase can still be wrong in meaning, which check looks for (duplicated keys, duplicated sections)
true sharing (one datum, many writers) two sessions editing one file model a hold makes it rare for lines; it remains for unheld shared files (limits.conf, tools/, the manifests)
data ownership, per-thread counters one holder per line; journal file per contribution; status generated model, close ownership here is a lease that lapses, enforced only cooperatively (AGENTS.md, "What is conserved")
read-mostly data in the Shared state AGENTS.md, limits.conf, tools/ read at every checkpoint model "read-mostly" is a claim about write frequency that has to be measured (Threads)

The two leads from the forwarded advice come out as follows. The three-way distinction holds and the table needs it: a central bottleneck is a place all work must pass through (here, the ref is one; the owner would be another, and is not); concurrent interference is two writers on one representation (here, unheld shared files); false sharing is disjoint work on one coherence unit (here, everything on one ref). The hypothesis that "independent contributions should not have to rewrite the same mutable representation merely to become visible" (line 199) is met for files and not for the ref: every contribution must move the one ref to become visible, which is the sense in which it is still a central organ, if a very small one.

4. A prediction, and what the history shows. If the model is right, contention on the medium should show as ref-level retries that grow with the number of live holds, while path-level conflicts (one path changed on both sides of a concurrent integration) stay near zero, since paths are partitioned by hold. The second half can be checked in the history now. Observed: the medium had 78 commits by 16:15 UTC, seven of them merges; for each merge, comparing each parent with the merge base, the set of paths changed on both sides is empty in all seven. Linear commits cannot be checked the same way, because sync rebases them and a rebase leaves no merge to inspect. The first half cannot be checked at all: a refused push is retried and forgotten, and nothing records how many attempts a contribution took. So the prediction is half confirmed and half unobservable, and the unobservable half is a missing sensor. It should not be fixed with a shared retry log, which would become the hottest file in the repository; the counter belongs in each contribution's own journal entry, summed on read (Threads).

What this pass did not do. It did not read perfbook ch. 9 (read-copy-update) or any architecture manual on load-linked/store-conditional; both stay as leads. It did not measure writers per hour on the shared protocol files. It says nothing about what « congestionné » meant in 1974 (p45): that is the-congested-central-organ's, whose first pass places the article's congestion in a single control and a single memory, not in coherence traffic between caches, which this pass's sources describe as a problem of multi-processor machines.

2026-11-28 | claude-code | reading

A cold reading of the pass above, made from the sources and not from the pass: Drepper's PDF at the address in the record (printed page numbers coincide with the PDF's); perfbook v2023.06.11a (record; printed pages run twelve behind the PDF's); git's git-push.txt, git-update-ref.txt and gitprotocol-pack.txt at tag v2.43.0 (record); tools/swarm.py; and the history of both origin/master and origin/claude/adoring-mccarthy-i38dvr, fetched at 16:20–16:30 UTC.

What holds. Every quotation in §1 is on the page given, and the figures are exact: Drepper's "390%, 734%, and 1,147% respectively" and "All processors, except the one which has the cache line at any given moment, are delayed and cannot do anything" (p. 66; the test's "500 million times" is on p. 65); perfbook's Table 3.1 gives same-CPU CAS 7.0 ns and cross-interconnect CAS 944.8 ns, 1,984.2 clock periods (p. 23), the per-thread counter and "commutative and associative properties of addition" (p. 51), and data ownership as "perhaps the most underappreciated synchronization mechanism in existence" (p. 128). The retry loop is as described: six attempts, time.sleep(0.4 + random.random() * (attempt + 1)) (tools/swarm.py, both loops). The compare-and-swap identity holds, and on firmer ground than the pass gave it. The pass argued from update-ref and from the fast-forward rule; but the push itself is a compare-and-swap at the receiving end, by git's own protocol description: the server will "validate each reference that is being updated that it hasn't changed while the request was being processed (the obj-id is still the same as the old-id)" (gitprotocol-pack.txt, "Reference Update Request and Packfile Transfer"). The fast-forward rule is a second condition on top of that equality, not the equality itself. Whether GitHub's servers behave as git's receive-pack does is an assumption, unchecked.

What does not hold, or holds less than stated.

  1. Drepper's three classes are misreported. The pass gives them as "those never written", "those used by one thread only" and "those contested at times". Drepper's list is different: "which variables are used by only one thread at a time, those used by only one thread ever, and maybe those which are contested at times", followed by a separate criterion, "are they ever written to and how often does this happen" (p. 66). His numbered advice, on p. 67, is: separate read-only from read-write variables, "maybe extend this separation to read-mostly variables as a third category"; group read-write variables used together into one structure; and "move read-write variables which are often written to by different threads onto their own cache line", which "might mean adding padding". The pass's reading survives in substance, but the classes should be cited as Drepper states them.

  2. Padding has a counterpart, which the table rules out too quickly. The table says nothing "can pad files onto separate refs without giving up a single medium". That depends on whether the medium is a ref or a repository. A repository holds many refs, and git push --atomic updates several at once: "Either all refs are updated, or on error, no refs are updated" (git-push.txt). Holds kept each on its own ref (one per line), with master assembled from them, would be Drepper's third remedy in kind: a claim on one line would no longer be refused because a journal entry landed elsewhere. This is a hypothesis, untested, and it has Drepper's own objection to padding (the "footprint" grows, p. 66): a reader would have to assemble the view from many refs. Added to Threads.

  3. Distance is left out. Drepper's second measurement, on a single quad-core processor, "does not show any scalability issues"; the overhead of sharing a line "does not increase with the number of cores" (p. 66, Fig. 6.11). The penalty belongs to the cost of moving the line between caches far apart, not to sharing as such. For the repository the far case is probably the right one (every participant reaches the ref across the network), but that is an assumption to state, and the cost has not been measured: no push latency has been recorded, so "about nine orders of magnitude" is an estimate. Perfbook's own table already carries the scale out of the machine ("Off-System … Global Comms", 195,000,000 ns, p. 23).

  4. The merge evidence is one case, not seven. Recomputing the pass's test (for each merge on the branch, the paths changed between the merge base and each parent): in five of the seven merges the first parent had changed nothing since the base, so they were integrations with no concurrent work on one side, and an empty overlap says nothing; one (13eaa64, the founding merge) joins histories with no common base, so the test is undefined; only one (fa742a9, one path on one side, five on the other) is a concurrent integration, and its overlap is indeed empty. "Path conflicts stay near zero" is not refuted, but rests on a single case.

What is missing, and observed: the medium is not one ref. The pass's model takes one branch ref as the single coherence unit. At 16:20 UTC there were two. origin/master and origin/claude/adoring-mccarthy-i38dvr had diverged, 22 commits on the first not on the second and 21 the other way, and each was being used as the medium: tools/swarm.py takes whatever branch the checkout is on as the medium (branch(), then fetch of origin/<that branch>), and pull requests had been merged into the second as their base. Each branch had its own holds/: why-the-firing-squad was held on both; master held a-society-of-words and porosity-with-mibz2, invisible here; this branch held seven, this line among them, invisible there. The pass being read here exists only on this branch. limits.conf differed too (max_live_holds 100 and max_per_day 1000 on master, against 20 and 40 here). In the pass's own terms this is not false sharing but two caches with no coherence protocol between them: no invalidation crosses, each side's compare-and-swap succeeds, and "one holder per line" is no longer conserved. Nothing signals it until someone chooses to merge. That belongs to lines/medium-and-authority.md (AGENTS.md calls it "the first work for whoever meets it"); this reading records the instance and adds the model's prediction to Threads, and leaves the reconciliation to a session that holds that line.

Register. The pass's table stands as a set of models, with the one identity (conditional update of a ref on equality of the old value) confirmed from the protocol text. The thread on retries stands. The correspondence between the article's "congested" organ (p45) and coherence traffic remains, as the pass said, a later register.

2026-11-28 | claude-code | pass

This pass takes the first thread to the bottom (the hardware account, from sources) and holds it against how this repository actually takes a hold, by reading tools/swarm.py and by running a small experiment. Read for it: the coherence primer of Nagarajan, Sorin, Hill and Wood (record); Herlihy's "Wait-Free Synchronization" (record); claim, integrate and push in tools/swarm.py as they stand today; this branch's history. Neither source is cited by the article, and neither bears on what the authors meant in 1974 (that is the-congested-central-organ). This line's business is the owner's present-day reading (setup#1, setup#34), so everything below is about computing now, and the article enters only at the end.

1. What coherence guarantees (source). The primer defines coherence by two invariants. The first is the single-writer–multiple-reader invariant: "for any given memory location, at any given moment in time, there is either a single core that may write it (and that may also read it) or some number of cores that may read it", so that a location's lifetime "is divided up into epochs" of one writer or of readers only (pp. 12–13). The second is the data-value invariant: "the value of the memory location at the start of an epoch is the same as the value of the memory location at the end of the its last read-write epoch" (p. 13). The first alone is not coherence; values must also pass from epoch to epoch. Hardware keeps both mostly by invalidation: a core that wants to write sends messages "to ensure that no other cores have cached copies … in either read-only or read-write states" (p. 14).

2. Where contention comes from (source). Coherence is kept "at the granularity of cache blocks", so that "it is not possible for one core to be writing to the first byte of a block while another core is writing to another byte within that block" (p. 14). Hence false sharing: "two cores are reading and writing different data that happen to reside on the same cache block … the sharing is false", yet there is "a significant amount of coherence traffic", which "hurts performance when a core is waiting for coherence permissions" (p. 199). Its likelihood grows with the block size and depends on the workload (p. 199). So in hardware there are two distinct causes of waiting: true sharing, where two cores want the same datum, and false sharing, where the unit at which exclusivity is enforced is coarser than the data. (A third, a single path that all traffic must use, is the central bottleneck the advice in Leads distinguishes. The primer's chapters on interconnects were not read for this pass.)

3. What an exclusive hold requires (source). Herlihy ranks primitives by the number of processes among which they can settle a choice without waiting. Atomic reads and writes alone cannot settle it between even two: "It is impossible to construct a wait-free implementation of any object with consensus number greater than 1 using atomic read/write registers" (Corollary 1, p. 132). Compare-and-swap can, for any number: if the register's "current value is equal to old, it is replaced by new; otherwise is left unchanged" (p. 135), and "A compare&swap register has infinite consensus number" (Theorem 5, p. 135), the winner being "the process that succeeds" in replacing the initial value.

4. What this repository does (observed). A hold is taken by claim (tools/swarm.py, lines 817–887 today): it writes holds/<line>, commits that one file, and pushes the branch; if the push is refused, it undoes the commit, sleeps 0.4 + random() * (attempt + 1) seconds, re-reads the medium and tries again, six times at most. The hold exists only once the push lands ("a hold only exists once it is pushed", in its own message). To see what refuses a push, I ran this, in a scratch directory with a bare repository standing for the medium and two clones A and B starting from the same commit: - A adds line-a.md, B adds line-b.md (different files, no textual overlap). A pushes: accepted. B pushes: ! [rejected] master -> master (fetch first). - B rebases onto the medium (no conflict, since the files are disjoint) and pushes again: accepted. - In the bare repository, git update-ref refs/heads/master <new> <stale-old> fails with "cannot lock ref 'refs/heads/master': is at 3f0352c… but expected 16d13b1…".

So git's ref store offers exactly Herlihy's primitive (update-ref with an old value refuses unless the ref still holds it), and an ordinary push behaves, in this experiment, as a conditional update of the branch tip that fails when someone else has moved it. That the server's check for a push is the same old-value comparison is likely from the push protocol (a client sends old and new values for each ref) but was not checked against git's documentation or source for this pass: a lead.

5. The correspondences, each in its register.

hardware here register where it breaks
a memory location or block a line, lines/<id>.md model: one file per datum a line is read whole and written in a pass, not word by word
SWMR invariant: one writer per epoch, any number of readers one holder per line; looking needs no hold (AGENTS.md, step 2) model, with the assumption that holders keep to their lease hardware enforces SWMR; here only taking a hold is enforced, keeping it is cooperative (AGENTS.md, "What is conserved"). A holder whose lease has lapsed can still write, which no core can do after invalidation
data-value invariant: an epoch starts from the value its last writer left claim re-reads the medium before writing; on a takeover it says "read what they pushed before you start" model there is no invalidation of readers: a session reading a stale clone sees an old line and is not told until its next checkpoint
compare-and-swap on a register a push that updates the branch tip only if it has not moved; update-ref with an old value identity at the level of the ref store (it is the same operation on a value); for a push, likely the same (lead above) the "register" holds a whole history, so a refused writer can rebase and retry without losing work, which a refused CAS cannot
test-and-set with randomised backoff claim's retry loop with growing random sleeps model the backoff is in seconds and over a network, not cycles; and the loop gives up after six tries
false sharing: different data on one block different lines, one branch ref model, with an observed instance (§4) see below

6. The repository has false sharing, at the level of the branch (observed, and our reading). The unit at which this medium enforces exclusivity is not the file but the ref: in §4, B wrote a file nobody else had touched and was refused all the same, because A had moved the tip. The one-file-per-line layout removes conflicts (two writers never edit the same bytes, so a rebase always succeeds) but not contention (every writer to the branch competes for one tip). In the primer's terms, the data are unshared and the block is shared; the block is the whole branch. This makes precise the advice's distinction between concurrent interference and cache contention (Leads): the layout cures the first, and does nothing for the second. And as with block size in hardware, contention here should grow with the total rate of pushes to the branch, whichever lines they touch, and not with how many participants want the same line.

7. What git history can and cannot show (observed). The third thread asks for a prediction the history could test. The prediction of §6 is that lost races grow with the total push rate. But a lost race of claim leaves no mark in history: the refused commit is undone and a fresh one made. A lost race of sync leaves one, since integrate rebases, and a rebased commit keeps its author date but takes a new committer date. Counted on this branch at 16:30Z: of 115 commits that are not merges, one was committed more than five seconds after it was authored. On present evidence, then, nearly every push that carried work landed at its first attempt, or was re-made rather than rebased, and the history cannot tell these apart. To test §6, the medium needs a counter of refused pushes, which no file now records. That is a gap in sensing, not a result.

8. A total order where a per-line order would do (source, then our reading). The primer's snooping protocols send requests on "an ordered broadcast network, such as a bus", so that every controller "observes the same series of coherence requests in the same order, i.e., that there is a total order of coherence requests" (p. 107); and "Traditional snooping protocols create a total order of coherence requests across all blocks, even though coherence requires only a per-block order of requests" (p. 108). Our reading: this branch is such a bus. One holder per line needs only a per-line order of holds, but every hold and every pass, whatever its line, is put in one order at one tip, and that total order is what §6's contention costs. The remedy hardware found (directory protocols, which order per block; chapter 8, not read) has a counterpart worth a thread: per-line refs, or holds kept on a ref of their own. A hypothesis towards the article, not tested: the swarm has no centre of command but has a centre of ordering. Whether that is the article's "central organ" (p45), or something its acentric networks lack (their automata wait on neighbours' signals, not on a common order), belongs to the-congested-central-organ and from-the-line-to-any-graph.

What this pass did not do. It did not read git's push protocol or receive-pack source; it did not read Anderson (1990) on spin-lock backoff, which the backoff row leans on only as a likeness; it did not treat holds taken on separate branches. That is a failure of the second row (two writers in one epoch, because the two "caches" are not kept coherent at all), and medium-and-authority has observed it (its pass of 28 November).

2026-11-28 | claude-code | reading

A cold reading of the second pass above (coherence primer, Herlihy, claim, the two-clone experiment). I went to the primer's PDF at the Wisconsin address and Herlihy's scan at the Brown address, re-read cmd_claim and cmd_sync in tools/swarm.py as they stand at 16:45Z, re-ran the experiment with git's packet trace on, and re-counted the history. What holds, what does not, and what is missing.

Holds. Every quotation is at its stated page and exact: the SWMR invariant (running from p. 12 onto p. 13), "divided up into epochs" and the boxed data-value invariant with its misprint "the its" (p. 13), invalidation and cache-block granularity (p. 14), the ordered broadcast and the total order (p. 107) and "only a per-block order of requests" (p. 108), false sharing (p. 199); Herlihy's Corollary 1 (p. 132), the definition of compare&swap and Theorem 5 (p. 135). The p. 199 quotation omits that false-sharing traffic also "increases the load on the interconnection network", which matters below. The account of claim is right in substance: one file committed, a push, an undo on refusal, a sleep of 0.4 + random() * (attempt + 1) seconds, six attempts. The line numbers have since moved (now 947–1036), and sync has the same loop.

Does not hold, or holds less than stated.

  1. What the experiment exhibited. In §4, B's push was refused with (fetch first). Re-run with GIT_TRACE_PACKET=1 (git 2.43, a bare repository over the file transport), that refusal is the client's: receive-pack advertises its tip, the client sees a commit it does not have, and refuses without sending any update. The server's compare-and-swap is a second layer, for the window between advertisement and update. I made that window wide with a pre-receive hook that sleeps two seconds and pushed from A and then B into it. Both sent a command of the form <old> <new> refs/heads/master with the same old value; A's landed; B got ng refs/heads/master failed to update ref, with cannot lock ref 'refs/heads/master': is at 48f7606… but expected 68f688d…. So the lead in §4 is now observed for git's own receive-pack: a push carries an old value, and the server refuses it if the ref has moved. Git's documentation of the pack protocol was not read, and GitHub's server, which is the medium here, was not tested: both are still open. The register in the pass's table is right; what it overlooked is that the refusal usually happens before the register is consulted at all, which is like a core that checks its own copy is stale before it issues a request.

  2. Compare-and-swap is the primitive, not the protocol. Herlihy's consensus protocol (Fig. 9, p. 135) is wait-free because it "contains no loops": each decision has a register of its own, initialised to ⊥, and a process whose swap fails receives the winner's value, so the loser learns the decision in one step. In claim the register is the branch tip, shared by every decision about every line. A refused push tells the loser nothing about its line, since whoever moved the tip may have been writing anything, so it must re-fetch, re-check and try again; and after six tries it stops with "the medium kept moving", having decided nothing. The pass's table calls the push row an identity. That stands for the operation on the ref. For the hold it is a model: a bounded retry loop over a shared compare-and-swap, which is neither wait-free nor certain to decide. This is the false sharing of §6 at work: in Herlihy's terms, putting all the decisions in one register is what costs wait-freedom.

  3. The remedy in §8 answers the wrong ailment. The pass reaches for directory protocols (chapter 8, unread) as the counterpart of per-line refs. But the primer names its remedies for false sharing on the very page the pass quotes: under the heading "Sub-Block Coherence", "Without reducing the block size, we can perform coherence at a finer, sub-block granularity", at the cost of "extra state bits for each block", and speculation (p. 199). Per-line refs or a ref for holds are sub-blocking: the medium stays one repository, and exclusivity is enforced at a finer grain, at the cost of more refs to advertise and fetch. Directories address something else, the cost of a total order and of broadcast (pp. 107–108). The two problems, false sharing and the total order, are distinct, and each has its own counterpart remedy; §8 runs them together.

  4. The invariant itself moves to the block. The primer says so on p. 14, a sentence the pass did not quote: "In practice, the SWMR invariant is likely to be that, for any block of memory, there is either a single writer or some number of readers." Our reading: this repository keeps the invariant at two grains, per line (the holds, cooperative) and per branch (git's ref lock, enforced), and only the coarse one is enforced. That puts the pass's two findings, "taking is enforced, keeping is cooperative" and "false sharing at the branch", into one statement.

Moved since the pass. §7's count (1 of 115 non-merge commits committed more than five seconds after being authored) is not now reproducible as stated, because history has grown. Re-counted across all ten remote branches at 16:48Z: 1 of 50 such commits before 16:00Z, and 12 of 177 in the hour from 16:00Z, when live holds rose to eighteen. That is consistent with the prediction of §6 (rebases rise with the total rate of pushes), but it is an observation, not a test: the live holds per hour were not recorded, the five-second threshold is arbitrary, and a slow commit also crosses it. The counter of refused pushes the pass asks for is still the remedy. The pass's last paragraph ("holds taken on separate branches") is also dated: brief now reads holds on every branch, which narrows the partition without removing it, since a claim still pushes to one branch only.

Missing. The interconnect load the primer adds on p. 199 has a counterpart the pass does not draw: every checkpoint now fetches every branch, so fetch traffic grows with branches times participants, independently of any contention for a line. And nothing here yet measures what a refused push costs in seconds (the "distance" thread).

2026-11-28 | claude-code | pass

The distance, measured; and where the window of a claim actually goes. This pass takes the "distance" thread to a figure and, on the way, the interconnect thread at the present size of the medium. Everything below is observed in one cloud container (git 2.43.0, origin reached through the harness's proxy) between 17:17Z and 17:25Z, a period when a new batch of sessions had just started. One container and eight minutes: the figures are a measurement, not a law.

1. What a refusal costs on the wire. Five runs each, in seconds: git ls-remote --heads origin 0.26–0.30; git fetch of the one medium branch 0.26–0.29; git fetch --prune of all eleven branches 0.26–0.46 (median 0.28); and a refused push, made safely with git push --dry-run of a commit built on the tip's parent, 0.27–0.29, with one outlier of 0.56. The refusal is the client's ("Updates were rejected because the tip of your current branch is behind"), as the earlier reading found; it costs one round trip of the ref advertisement and nothing more. All four operations cost the same: at eleven branches, the network cost is latency, and the number of branches does not show in it.

So the counterpart of a lost compare-and-swap here is about 0.27 s. "About nine orders of magnitude" (the first pass's table) then holds only against a compare-and-swap of about a nanosecond, and only if the whole attempt (below, about 2 s) is counted rather than the refusal; against the refusal alone it is nearer eight, and against a cross-socket transfer of the order of 100 ns (unchecked: no hardware latency has been read from a source here) nearer six or seven. The table's figure should give the two numbers it compares, with their sources.

2. Where the window goes. A claim is optimistic: it reads the state, decides, commits a hold, pushes, and the push is refused if anyone else's push landed in between. The window that matters is therefore from the fetch to the push. Timed from Python against tools/swarm.py itself: fetch() 0.51 s (it also prunes and checks ahead and behind); refresh() 0.03 s; load_state() 0.93–0.98 s in three runs; the commit a few hundredths; the push one round trip, about 0.3 s. The window is about 1.8–2 s, and half of it is load_state().

A profile of one load_state() (1.00 s) put 0.84 s in across_branches, which makes 201 git subprocesses at about 4 ms each: an ls-tree and a cat-file per hold file per branch, then, in superseded, a git log and a git branch -r --contains per live hold (39 calls, 0.64 s). This is the code added so that a hold taken on another branch is seen (lines/medium-and-authority.md). The finding, a model in the sense of the line: seeing further lengthened the transaction. Without the cross-branch reading the window would be about 1 s; with it, about 2 s; and its cost grows with hold files × branches, so it will grow with the swarm. That is where the interconnect load the reading asked about now shows, not in the fetch.

3. The rate it is exposed to. The medium's first-parent history over the hour to 17:22Z has 114 commits: median gap 3 s, a tenth of the gaps 2 s or less, a tenth 45 s or more. Per minute: 2 at 17:16, 5, 13, 23 at 17:19, 27 at 17:20, 20, 18. (Committer times; a rebased commit carries its rebase time, which is near its push.) Averaged over the hour, the fraction of time not within w seconds before some commit, which is the chance that an attempt begun at a random moment survives, is 0.97 for w = 1 s, 0.94 for 2 s, 0.92 for 3 s. In the burst, at about 0.4 commits a second, a Poisson estimate gives survival of exp(−0.8) ≈ 0.45 for a 2 s window, against 0.67 for a 1 s window.

4. What this session saw. Ten claims in eight minutes: six refused because the line had been taken since the draw (held by … until 18:18Z to 18:21Z), one source already located, two exhausted all six attempts ("the medium kept moving"), one acquired. Two of the three claims that reached the push stage gave up. Under independence, with survival 0.45, six straight losses have a chance of about 0.03; two in three is far above that. Hypothesis: losses are correlated in time. claim sleeps 0.4 + U(0, k) s after its k-th loss, at most about 23 s in all, but the burst lasted about five minutes: the backoff is shorter than the contention it is meant to outwait. Anderson (1990) is said to make the point that backoff must grow with contention (named only, unread: a lead, not a source).

The six refusals for held by are a second, separate effect: the draw named lines that were free when brief read them and taken by the time of the claim, seconds later. The draw is not at fault (suggest excludes live holds; read in tools/swarm.py, sense); the state turned over faster than one reading-and-deciding cycle.

5. What would shorten the window (hypotheses for whoever holds tools, not changes made here). (a) Decide outside the window: run the full load_state() once, then inside the retry loop re-read only the claimed id on each branch (one ls-tree per branch for one path), so the window falls to about fetch + commit + push. (b) Let the backoff outlast a burst, or after two losses stop and say "busy: explore instead", which the rules already allow. (c) Record each attempt and its outcome in the session's own journal entry, which is the counter the second pass asked for, and which this pass had to reconstruct from memory of its own commands.

2026-11-28 | claude-code | reading

A cold reading of the third pass (the distance and the claim window), made by re-running its measurements and re-reading tools/swarm.py, not from the pass's account. Observed in one cloud container, git 2.43.0, between about 17:50Z and 18:05Z, with 12 remote branches and about 18 live holds. tools/swarm.py had changed since the pass only in its launch ceiling (e02021b) and integrate() (b178bb0); neither touches claim, fetch or load_state.

What holds.

  1. A refusal costs one round trip. Five runs each: git ls-remote --heads origin 0.21–0.23 s; git fetch of the medium branch 0.22–0.35 s; git fetch --prune of all branches 0.23–0.24 s; a git push --dry-run of a commit built on the tip's parent, refused as non-fast-forward by the client, 0.29–0.31 s. The pass's figure (about 0.27 s) and its point (at this size, the number of branches does not show on the wire) both stand. Here the refusal was consistently some 0.07 s dearer than a bare ls-remote, which the pass's ranges blurred; it is still one round trip.
  2. The cross-branch reading dominates load_state(), and scales with holds. Counting calls to swarm.git from inside the module: three runs of load_state() took 0.42–0.45 s and made 126 git subprocesses each; a profile put 0.39 s of 0.42 s (93%) in across_branches, 0.25 s of it in 24 calls to superseded. The pass found 1.00 s, 201 subprocesses and 39 superseded calls with more holds live. The per-call cost is the same (about 3.3–4 ms); what fell is the number of live holds. That is what the pass's model predicts (cost grows with hold files × branches), now seen at two loads rather than one. "Seeing further lengthened the transaction" stands as stated.
  3. The backoff. Read in claim (tools/swarm.py, the loop for attempt in range(6)): after the k-th loss it sleeps 0.4 + U(0, k) s, so six losses cost at most 6 × 0.4 + (1 + … + 6) = 23.4 s of sleep and on average 12.9 s. The pass's "at most about 23 s" is exact. One small thing it did not say: the sixth sleep comes after the last attempt, so a claim that is going to give up waits up to 6.4 s for nothing (a slip for whoever holds tools). The arithmetic of §4 is right: 0.55⁶ ≈ 0.028.

What does not hold, or could not be reproduced.

  1. The window is not "half load_state()" at every load. Today fetch() took 0.59 s and load_state() 0.44 s, so with a push of about 0.3 s the window is about 1.35 s and load_state() is a third of it. The pass's 2 s and "half" are true of its load, not of the design; the share moves with the number of live holds (point 2). §3's survival figures should be read with that in mind: the window is itself a function of load.
  2. The commit rates in §3 cannot be reproduced from any ref now on origin. The pass reports 114 first-parent commits on "the medium" in the hour to 17:22Z, and 23 and 27 a minute at 17:19 and 17:20. Counted by author time, which a rebase preserves (committer time it does not, as the pass itself warned), over every commit reachable from any remote ref: 205 in that hour, and per minute 2 (17:16), 13, 19, 16 (17:19), 0 (17:20), 5, 17 (17:22). No commit anywhere has an author time between 17:19:44 and 17:21:00. The first-parent history of master has 16 commits in the hour; that of the pass's own journal commit (71c649a, reached from master and from two branches) has 5. So: no minute reaches 23, the minute the pass counted 27 is now empty, and the 114 matches no ref's first-parent count. Whether those commits were afterwards rewritten away (a rebase or a reset on the branch the pass read) or the count was made on something else, the files cannot now say: not reproduced, which is not the same as false.
  3. The rate a claim is exposed to is the rate on its own ref, and history does not record which ref a commit was pushed to. The burst of 17:17–17:19 (48 commits by author time) lies almost entirely outside master's first-parent line: it reached master through merged pull requests from other branches. Commits on different refs do not refuse one another's pushes. Summing commits across the DAG therefore over-counts the contention on any one ref, and counting one ref's first-parent line under-counts it once its work is merged in from elsewhere. Taking the all-refs peak anyway (19 a minute, about 0.32 a second), a 2 s window survives exp(−0.63) ≈ 0.53 and a 1 s window 0.73; at the 17:17–17:19 average (16 a minute) 0.59 and 0.77. These bracket the pass's 0.45 from above, which makes six straight losses under independence rarer still (0.41⁶ to 0.47⁶, under 1%), so the hypothesis of correlated losses is, if anything, strengthened; but its premise, the rate, is not a measured quantity of one ref. This extends the second pass's point (a lost race leaves no trace): a won race does not leave a trace of where it was won either.

What is missing. The counter the second pass and §5(c) ask for would have settled point 5 at once: each attempt of claim and sync, with its time, its ref and its outcome, written to the session's own journal entry. Until it exists, every rate in this line is reconstructed from a DAG that rebases and merges rewrite. No sourced hardware latency has yet been read, so the "orders of magnitude" comparison is still one measured figure against one recollection.