OverviewFilesCommitsIssuesDocsReleasesPeers

keet-daemon commits / e2793d5

CPP-PORT-DESIGN: R4c-0 measured hops
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e2793d5734b1eedd09e5a89323097c5851eab824
by plankatron <fleeky@gmail.com> · 2026-10-06T19:50:52.000Z

Changed files (1) +36 -0

docs/CPP-PORT-DESIGN.md +36 -0
……@@ -3815,6 +3815,42 @@ injected per layer:
38153815 Drill set r4c-mig.
38163816 - During R4c-2..3 the old synchronous L2 stays, renamed `l2sync` and frozen, so every
38173817 commit builds. R4c-4 removes it.
3818- **R4c-0 DONE 2026-10-06: hypercore-storage 3.3.0's hops, MEASURED** (keetd 4ba3735 `tools/l2/hops.js`,
3819 Bare at `UV_THREADPOOL_SIZE=1`, two runs byte-identical). The ruler starts at the top of each
3820 rocksdb-native completion (batch `_onread` / `_onwrite`, iterator `_onopen` / `_onread` / `_onclose`),
3821 or at the call for ops that touch no db.
3822 - Getters, after the read completion:
3823 - 1 hop: `getBlock` (it returns `view.get`).
3824 - 2 hops: `getHead`, `getAuth`, and `getTreeNode` with no cache (`async` + await + decode).
3825 - Mixed in one batch, they settle in that order: getBlock first.
3826 - Tree cache:
3827 - A miss (fork 0) lands at 3 hops after the read, through `_resolveTreeCache`. A parallel second
3828 call on another rx shares that entry: 3 hops, no read of its own.
3829 - A hit lands 1 hop after the call.
3830 - CoreTX.flush:
3831 - with no view (View.flush): 3 hops after the write;
3832 - a second call (changes null): 1 hop after the call;
3833 - into an atom's view: 1 hop after the call.
3834 - View, through an atom: a hit is 1 hop after the call; a miss goes to the db, 2 hops after the
3835 read.
3836 - Atom.flush:
3837 - with no handlers: 5 hops after the write;
3838 - with one async handler: the handler runs at 3 hops, and `flushed()` and `flush()` both settle
3839 at 6, flushed() first.
3840 - Store ops:
3841 - `getSeed` and `hasCore`: 3 hops after the read;
3842 - `setSeed`: one read, one write, settling 7 hops after the write;
3843 - `createCore` (new): 7 hops after the write.
3844 - **Group commit, measured:** two overlapping `setSeed` calls make two reads (each under the lock,
3845 one after the other) and ONE write. #1 settles at 6 hops and #2 at 7.
3846 - Streams:
3847 - A plain block stream emits every entry, then `end`, 1 hop after the iterator read. `close`
3848 comes 0 hops after the iterator close.
3849 - An overlay stream emits the db's entries 2 hops after the read. View entries sorting past the
3850 db's last key (`data 5`), then `end` and `close`, come 1 hop after the iterator CLOSE
3851 (OverlayStream `_onclose`). A deleted key is dropped.
3852 - ScopeLock: a free `lock()` resolves 1 hop after the call. A queued one resolves 1 hop after
3853 `unlock()`.
38183854- **Then 4e-4** (`createProtocolStream` / `replicate`): the first gate that composes the stack
38193855 is a COMPOSED trace against JS (secret-stream + protomux + replicator), now meaningful.
38203856