Skip to content

CLI-96: a counter for each partition, as the option sequence of the store - #463

Merged
mark1russell7 merged 11 commits into
mainfrom
feat/cli-96-partition-counter
Nov 9, 2026
Merged

mark1russell7 merged 11 commits into
mainfrom
feat/cli-96-partition-counter

Conversation

@mark1russell7

@mark1russell7 mark1russell7 commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

What

Form A of CLI-96, as an option of the store: sequence: "partition" gives each partition its own counter of the numbers and its own write queue. The default collection keeps the behavior of today. #450 has the readings that chose this form.

  • The counter. The _id of the counter of a partition is seq + U+001F + the collection + U+001F + the partition. A store without a partition uses the empty text.
  • The refusal of a live collection. A store with the option marks the counter of the collection once for each client, in one atomic step, unless that counter has numbers. With numbers, the store refuses each write and each change read with a clear error. A failed check tries again at the next call.
  • The refusal in the other direction. A store with the default reads the mark in its own steps on the counter of the collection, so it needs no extra read. In a transaction, the error aborts the transaction. On the watermark path, the store ends its pending range first.
  • The own writes of a watcher. Two partitions can have the same number. So a store with the option notes each number with its partition, and the watcher takes it with the partition of the event.
  • A view target. The materializer gives its target storage the sequence of the given storage.

The conditions of the ruling

The merge ruling of 2026-11-09

The writesInFlight sweeps at 4000-p2 answer the hold of 2026-11-07. With bounds of 2 to 16, the partition arm has 0 aborts. The control arm has 231.5 to 3,275. The writes per second agree, with a ratio of 0.985 to 1.002.

  • The unbounded case is a loss: 638.5 against 916.5 writes a second (run 42428048767). The doc of writesInFlight gives this cost, and such a store emits one process warning.
  • A unit test locks the default bound at 8.
  • The gate row of form A at 200 writes a second on each CPU model (bench(mongo): forms of the numbers of a store #450) is the next item of the mongo line. It comes before each other change to sequence or writesInFlight.

The CPU models of the 4000-p2 sweeps

Each run had three jobs. The medians pool the jobs, so each row mixes CPU models.

Bound Run CPU models of the three jobs
2 42427971112 2 AMD EPYC 7763, 1 Intel Xeon 6973P-C
4 42427992243 2 AMD EPYC 7763, 1 AMD EPYC 9V74
8 42428012788 1 AMD EPYC 7763, 2 Intel Xeon Platinum 8573C
16 42428031142 2 AMD EPYC 7763, 1 AMD EPYC 9V45
Infinity 42428048767 2 AMD EPYC 7763, 1 AMD EPYC 9V74

The gate row reads each CPU model by itself. A model in this table gives a repeat there, and a model outside it gives new evidence.

Tests

  • The contract of CollectionStorage runs with the option on both paths of the numbers.
  • New rows read the counters of two partitions and the change log of each partition. Other rows read two clients on a new collection, a collection with only a read, and each refusal.
  • A watcher row: a note of one partition does not hide the same number of another partition. A unit row reads the keys of the notes.
  • Locally: typecheck clean. vitest related gave 63 passed and the MongoDB rows skipped. The MongoDB rows run in CI.

Release

PATCH of @procedures/mongo: a new optional field, with a default that keeps the behavior (strategist ruling of 2026-11-05 23:41Z). It merges after 0.48.2.

🤖 Generated with Claude Code

mark1russell7 and others added 4 commits November 5, 2026 18:48
…the store (CLI-96)

The option sequence: "partition" gives each partition its own counter and
write queue, so two partitions share no document. A store with the option
marks the counter of the collection once, and refuses a collection with
numbers there. A default store reads the mark in its own counter steps and
refuses too. The own-write notes of a watcher take the partition, because
two partitions can have the same number. A view target takes the sequence
of its storage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without transactions, the release fence writes lastRelease on the
counter. The check of each counter compared the whole document, so the
run with transactions "never" failed on MongoDB. counterOf already
leaves out the epoch and the pending numbers. It now also leaves out
lastRelease, the third field of the write state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…CLI-96)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The watermark of CLI-91 (#447) reads the counter and the floor in one command and writes only on the first read. CLI-96 keys it by the counter of the store, checks the sequence first, and reads the mark of the sequence. The read and write queues are keyed by the counter of the store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mark1russell7

Copy link
Copy Markdown
Owner Author

Held. Ladder run 2 (https://github.com/mark1russell7/client/actions/runs/42384941897) gives at 800 writes per second with 2 processes:

Arm Abort share, median Abort share, worst Write conflicts, median
control 0.2114 0.2555 4,277
partition (this PR) 0.178 0.2168 3,474

The rule is 0.01. This PR removes about a sixth of the aborts, so the cause of the rest is not shown. The next step counts the write conflicts per collection and key in both arms. If most conflicts are on the counter and queue keys, this PR stays and the rest gets its own fix. If not, this design is wrong and the PR closes.

mark1russell7 added a commit that referenced this pull request Nov 7, 2026
…(CLI-96)

With a counter for each partition (#463), the update of the counter has
the id this.counterId, not this.collectionName. The copy rule looked only
for the old text, so the rules test of the probe of 8000-p2 stopped the
job before a measure (run 42408939627). The rule takes the id that the
source has, and a new test covers the id of #463.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mark1russell7 added a commit that referenced this pull request Nov 7, 2026
The test made the id of #463 from the source of main, so it failed on a
tree that has #463. It finds the id of the source and makes both forms
from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e (CLI-96)

A set of a new id and a rewrite send a fixed list of commands. The test counts
them with the command events of the driver, for the collection counter and the
counter per partition, so a change of the cost of a write fails in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each partition had its own write queue, so a process kept one open transaction
for each partition. The new option bounds the writes of each client, over the
stores with the same value. A write takes its permit after its turn in the queue.
The default of 8 is provisional: the bench sweep of 1 to 16 at 400-p2 sets it.
A test on the CI replica set counts the open transactions against the bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mark1russell7

Copy link
Copy Markdown
Owner Author

The two sweeps of writesInFlight set the default of this PR. The default stays 8.

The 400-p2 sweep is under the ceiling of the store. The writes per second are flat there, and only bound 1 fails its p99.

The 4000-p2 sweep is over the ceiling. Each line gives the partition and control writes per second (medians), and the ratio:

Bound Partition Control Ratio Partition aborts Open requests (max) Run
2 966.1 978.3 0.988 0 3 42427971112
4 1147.2 1164.2 0.985 0 5 42427992243
8 1265.5 1270.2 0.996 0 10 42428012788
16 1287.8 1285.7 1.002 0 18 42428031142
Infinity 638.5 916.5 0.697 857.5 19864 42428048767
  • From 4 to 8, the rate goes up by 10.3 %. From 8 to 16, it goes up by 1.8 %, and the open requests double.
  • The bound also changes the control arm. Its aborts go up with the bound: 231.5, 779, 1663, 3275 and 27120.
  • Both arms stop at approximately 1290 writes per second, so the store is the limit at 4000/s.

🤖 Generated with Claude Code

mark1russell7 and others added 3 commits November 7, 2026 22:34
The change reads use withReadPermit of main (CLI-102, no read queue).
The write bound of CLI-96 wraps enqueueWrite of main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lections

The merge of main brought #489, which replaced the local Semaphore class.
writesInFlight takes semaphore(bound) and run(). The doc of the option
names the sweeps that set the default of 8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mark1russell7
mark1russell7 marked this pull request as ready for review November 9, 2026 17:37
…each partition

The strategist's conditions of the merge of #463: a test locks the
default bound at 8, the doc of writesInFlight gives the cost of Infinity
with sequence "partition" (638.5 against 916.5 writes a second, bench
run 42428048767), and such a store emits one process warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mark1russell7
mark1russell7 merged commit 3914b5f into main Nov 9, 2026
26 checks passed
@mark1russell7
mark1russell7 deleted the feat/cli-96-partition-counter branch November 9, 2026 20:18
mark1russell7 added a commit that referenced this pull request Nov 9, 2026
The files of #435 take the side of main (it merged as a squash). The
files of this branch merge with the base 2c32aa8. The copy of many
counters takes the counter id of #463 from #480 (b8d5cbb), because
main names the counter this.counterId. The changeset of #435 left with
its release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mark1russell7 added a commit that referenced this pull request Nov 9, 2026
…rtition store (#480)

* test(mongo): reproduce a delta read that a prune of another process passes

The test holds a delta read between its read of the floor and its query.
A second process then deletes an item and prunes the older tombstone.
This test is red on this commit if the short delta is real.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mongo): check the floor again after the query of a delta read

A prune raises the floor before it deletes the tombstones. So a query
that missed a tombstone now sees the new floor, and that reader gets a
full result. A silent short delta is no longer possible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mongo): one queue for each client, and a test that holds a prune between its steps

The queue of the writes and the change reads now belongs to the client. A db
option that makes a new Db at each call, and the default connection, had no
queue. A second process of a test holds its prune before the second step, so
a read between the two steps pins the order of the steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(mongo): a prune that stops between its steps leaves a full result, and the next prune finishes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(changeset): state the throughput of the stores that get a queue

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci(mongo): a speed gate of the store and a bench of different views

A pull request that changes the store now compares its reads and writes
with its base on a real MongoDB, with an A/A beside them. The base arm is
the whole source of the base commit. The limit stays a first value until
five CI runs give it, and the gate refuses it before that.

The suite views starts 1,000 views whose pipeline texts all differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the write bench keeps one error of each kind

A count of failures with no message cannot tell the cause, so each line
now has the count and the first message of each kind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci(mongo): the limit of the speed gate from five CI runs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the writes of tenants in one collection, with first loads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the load package in the lockfile

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the speed gate times the median burst of a child

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the type of the arm, and the name of a reading

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the name of a reading

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): two names of a reading in the tenant report

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci(mongo): the speed gate reads a claim over the pairs of two jobs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(mongo): the second look of the verdict test takes three stalls

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci(mongo): the store gate reads both looks and a limit per case

gate-margin refuses records that stop before the last look, because
those records give only an upper bound. It prints the formula for each
case alone and reads all cases together at those limits. gate-reruns
counts the no reads of a pull request and the reruns that follow them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci(mongo): the store gate takes a limit for each case

Each case has its own limit and its own stated slowdown. A case can be
report only: the gate reads and prints it, and it has no part in the
outcome or the level. With --enforce the report refuses a limit at or
over its stated slowdown. gate-margin prints the smallest slowdown each
case can hold on same-source records. That read is arithmetic: only a
flip proves a slowdown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(mongo): limits per case at the level of the whole family

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(mongo): the limits of the other runs, read on the run left out

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the read cases state 1.25, and one-10 states 1.40 as report only

The gate holds a slowdown of 25 percent or more in each gated case. A
slowdown under 25 percent can pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(mongo): the speed gate holds a slowdown of 25 percent, and a smaller one can pass

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): each case of the store gate prints its claim from the flip runs (CLI-94)

gate-limit.json holds the flip runs read so far. caseClaim gives the smallest
slowdown that each counted run held, with 2 or more runs, its k of n, the look
of each block and the 95 % Wilson lower bound, which is reported, not gated.
A block at a smaller slowdown counts at a larger one, and a miss at a larger
slowdown counts at a smaller one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): each claim of the store gate shows the runs that break its counting (CLI-94)

The counting assumes that the detection rises with the slowdown. The field
breaks lists each miss at a slowdown larger than a block of another run, and
the gate prints it. The three flip runs show none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(mongo): the record of the tenant write bench (CLI-95)

The rate of one collection, its limit against the runner, the queue against the counter (run 41973557472) and first loads. Each pass is provisional, because the rate of a tenant is a first guess.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(bench): the copies of tenant-separate follow the renamed write queue

The store now has enqueueWrite and enqueueRead, so the copy with no queue
did not find its text and the job stopped. The copies move to
bench/tenant-copies.ts, and a test in the CI step of the tenant suites
finds a lost text before a run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci(stream-cost): run each step in bash with pipefail (CLI-95)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the suite tenant-partition, the ladder gate of CLI-96

The arm partition is the store with the option sequence partition, so each
partition has its own counter and its own write queue. The suite runs it
beside the control at 800 and 8,000 writes a second, with one, two and four
processes. The report gives each rung of the arm, and a new abort rule:
with two processes or more, at most 1 % of the transactions of a child
abort. The copy many follows the counter id of the partition sequence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit cd44c6b)

* bench(mongo): each rung of the ladder gives its processor time for each write and the limit that stopped it (CLI-96)

A rung that does not pass names the runner (a late driver, the processors of
the runner at 0.9 or more, or one writer at 0.9 of its processor) or the design
(the abort rule, or a failure with free processors). A rung with only the
runner as its limit gives no reading of the partition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 1d2c296)

* bench(mongo): a tenant writer gives the time of its first writes, and a stopped writer fails its arm at once (CLI-96)

The first ladder run (42183250982) lost all three jobs. The control arm at 8,000 writes a second ran past the cap of 240 s, with no stderr. The records of the rounds that ended were lost too, because the upload ran only on a pass.

- tenant-writer: the time of the first writes of its stores (40,000 at 8,000 w/s) goes to stderr and to the result line.
- tenant-arm: the record has `warmMs` for each writer. A writer that ends with no result line fails the arm at once, with its code and signal. Before, the arm waited until the cap killed it.
- tenant-report: each arm gives the median and the worst `warmMs`.
- stream-cost.yml: a failed job also uploads its records.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 3c37648)

* bench(tenant): spread the tenants of the processes apart (CLI-96)

tenantOf gave the arrivals 2k and 2k + 1 one tenant from two processes,
about 1 ms apart at 800 writes a second. So each write raced a write of
the other process on one counter, in both arms (ladder run 2: aborts
0.21 control, 0.18 partition). The turn of each process starts
active / processes tenants later, so two writes of one tenant are about
active arrivals apart. One process keeps its order.

A test pins the spread. A flip with the old function fails it with a
distance of 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ee4e9fb)

* docs(bench): approximately for a quantity in tenantOf (STE)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f909ed9)

* bench(tenant): the ladder without the partition store (CLI-96)

The ladder and the fix of tenantOf go to their own branch, so the bench
does not ship inside #463, the change that it measures.

- The arm partition stops when the store has no counter for the partition
  t0. A store without the option sequence ignores the option, so without
  this check the arm measures the counter of the collection under the name
  partition.
- tenant-copies.ts keeps the text of the counter of this tree. The change to
  counterId belongs to the store change of #463.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): an empty changeset for the partition ladder (CLI-96)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): one CI job for each tenant case, and the server in the load (CLI-96)

The plan of stream-cost.yml reads SUITE_CASES from bench/tenant-cases.ts,
so each case of a tenant suite has its own CI job. A slow rung no longer
holds the job of the other rungs, and the warm phase stays inside the
measure. The input case picks one case. tenant-jobs.ts joins the files of
one job before poolRecords.

Each tenant arm reads serverStatus at the start and the end of the load:
the lock waits, the write time inside the server and the eviction by the
threads of the application. The input server_samples adds one sample
each second: tickets, the queue of writers and the dirty cache. The
probe of 8000-p2 reads them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the copy of many counters finds the counter id of #463 (CLI-96)

With a counter for each partition (#463), the update of the counter has
the id this.counterId, not this.collectionName. The copy rule looked only
for the old text, so the rules test of the probe of 8000-p2 stopped the
job before a measure (run 42408939627). The rule takes the id that the
source has, and a new test covers the id of #463.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(bench): the counter test of the copies holds on any tree (CLI-96)

The test made the id of #463 from the source of main, so it failed on a
tree that has #463. It finds the id of the source and makes both forms
from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): a lock with no wait yet reads 0, not null (CLI-96)

MongoDB adds timeAcquiringMicros to a lock only after its first wait.
The probe of 8000-p2 read null for the collection lock in each child,
so the bench measured nothing. A lock with no such field gives 0 now,
and only a lock that the server does not give gives null.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the spread of a tenant run over its keys and processes (CLI-96)

Each row of a tenant run gets the field spread: the planned writes and
the replies of each key, the share of the top 1 % of keys, the median
time of each key over the keys, and the replies of each process. So a
probe tells a hot partition key from a slow round or a slow process.
The server gives no ticket wait for each key, so the time of a write
from its plan to its reply is the measure of a key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the rungs 2000-p2 and 4000-p2 of the suite tenant-partition (CLI-96)

The 8000-p2 probe filled the runner in both arms, so it gave no reading
of the design. The rungs of 10,000 and 20,000 active tenants find the
last rate where the runner is not the limit. The rules step of the
workflow also runs the spread test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): commits and open transactions of the tenant arms (CLI-96)

The arm took starts minus aborts as the done transactions. A transaction that is
open at the reading after the writers exit is neither. The record gets
transactionsCommitted and transactionsOpen from serverStatus, and the report gets
the commits of each finished write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the input writes_in_flight for the sweep of the write bound (CLI-96)

The tenant writers give the value to the option writesInFlight of their stores.
A writer stops when the store of its tree has no such option, so no row reads
the wrong store. Each count line keeps the value, and the report gives it per
case. The sweep of 1, 2, 4, 8 and 16 at 400-p2 sets the default of the store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the case 400-p2 of the partition suite, for the sweep (CLI-96)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(bench): the rung 400 in the rates of the partition suite (CLI-96)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* bench(mongo): the gate row of a partition at 200 writes a second (CLI-96)

The suite tenant-partition gets the cases 200-p2 and 200-p4, the stated
limit of a partition. A dispatch with one case starts only that row.
The spread test and the rate test cover the new rung.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant