Repository navigation
Commit 38e00f3
TradeLedger: a sink run keeps the read cache at a fixed 128 rows
PR #496's kernel leg failed test_selected_metrics_l17b (sink heap-flatness
witness, 12 checks): the ledger read cache was allocated by the consumer's own
closed-row reads and grew with the closed-trade count to 65,536 x 312 =
20,447,232 B in sink runs, against a budget of 2 x kScratchWindowBytes with
large <= small + window. Owner rule: the witness is not loosened.
At run begin the consumer now sets the ledger cache budget from the run mode:
TradeLedger::kSinkCacheRows = 128 rows (128 x 312 = 39,936 B, under one 64 KiB
scratch window, independent of the trade count) when a report sink is
installed, the default 65,536 rows otherwise (sink-off runs, which is how the
verifier and the sweep run, are unchanged). set_cache_rows is called on a
freshly cleared ledger, so it cannot hit the frozen refusal, and it runs every
begin so a reused handle never keeps a stale sink budget.
Arithmetic against the witness: other working storage 65,592..65,928 B (window
plus 56..392) + 39,936 = at most 105,864 <= 131,072 (2 windows); small (1k
trades) and large (100k trades) both allocate exactly 128 x 312, so large - small
= 0 <= window. A static_assert in test_p2cx_tledger_budget pins
kSinkCacheRows x kLedgerEntryBytes <= 64 KiB. Mutations: the sink branch using
the default budget (l17b red); every run using the sink budget (the hungpixi-shaped
I/O test red).
Based on ef4c628 (nothrow operator new fix).
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>1 parent ef4c628 commit 38e00f3
3 files changed
Lines changed: 18 additions & 0 deletions
File tree
- include/pineforge
- src
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3166 | 3166 | | |
3167 | 3167 | | |
3168 | 3168 | | |
| 3169 | + | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
| 3173 | + | |
3169 | 3174 | | |
3170 | 3175 | | |
3171 | 3176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
11 | 21 | | |
12 | 22 | | |
13 | 23 | | |
| |||
0 commit comments