Cache retention drops each minute's new entries once its page cursor reaches the newest entry #87

Closed
opened 2026-11-16 13:58:44 +00:00 by xemmerling · 0 comments
Owner

Production b5c5b140, read-only readings of 13:30 to 13:57Z 11-16. Since about 09:45Z today the cache's retention pass drops, every minute, exactly the entries stored in the minute before, unless something used them meanwhile. A head cannot find what the head before it compiled.

What the pass does. read_page (src/jobs/cache/retention.rs) reads WHERE seq > $after ORDER BY seq LIMIT $size and starts a new round only when a page comes back empty. With puts arriving every minute a page after the newest entry is never empty, so once the cursor has reached the newest entry it stays there: each pass reads only what was put since the last one. Earlier drops have drained the pool, so the pool is those new entries alone; their bytes do not cover the excess, and drop_for lets every candidate go. The pass's own lines say it, read equals dropped in every one of the 62 passes between 12:43Z and 13:47Z:

13:35:51 short=107250575769 pending=38449458529 read=1202 dropped=1202 freed=13120730242
13:36:52 short=122980845977 pending=51570188771 read=641  dropped=641  freed=12360426315
13:37:53 short=132056279449 pending=63930615086 read=164  dropped=164  freed=5694278108
13:46:09 short=138016692633 pending=96788536638 read=1255 dropped=1255 freed=9629229920

Sums over the 62 passes: read 39,997, dropped 43,858, freed 552 GB, mean short 125 GB. The spec's sentence it breaks is the module's own: "every entry is looked at once in each round of pages", and "worth alone decides".

What stands in entries, by the hour stored (13:56Z):

stored in hour (UTC, 11-16) standing of them never used
13 121 110
12 1,070 0
11 143 0
10 1,888 0
09 10,428 4,711
08 38,580 30,240
07 42,133 31,848
06 43,235 32,419

New puts were 12,545 to 33,511 an hour in those hours (Prometheus, t_cache_puts_total{stored="new"}); t_cache_entries_dropped_total{why="trimmed"} was 15,944 to 28,899. So from 10:00Z on about nine in ten new entries are gone within a minute, and the only survivors are those hit before the next pass (drop_candidates spares what was used since it was read). The same shape, hours with no never-used entry left, shows on 11-15 21:00 to 23:59Z, 11-15 01:00 to 05:59Z and 11-14 22:00Z: each time until a restart put the cursor back at the start (23:46Z 11-15; today's last was 07:56Z, and the round reached the newest entry between 09:15 and 09:45Z).

How it showed. Four head runs in a row (jobs j587-14864, -15404, -16798, -17264) each compiled and stored the same 65 units of tilo's wasm page bundle (m in the jobs' own .t-cache-counts; 1,380 hits, 20 not stored). Between two of those heads (tilo ba938bf3b08 and 0508acbb34) four files changed, none in those crates. entries holds no wasm entry of tilo-actions at optimisation 1 stored after 09:45:07Z. That build is 18 of the 33 minutes of test/tilo-session-client in each head (#74). It is how I found this, not its measure: 38 of 45 heads in the last 16 hours changed a crate that build reads, and that job was as long in the hours when entries stood. What this fault costs is wider: every unit whose key changed since the cursor stuck is compiled again by each head after, in every family, because no head's entry of it stands.

What I am doing. This restores the module's stated rule, so I take it as a fix, not a design change: a round ends when a page reaches the newest entry (a page shorter than asked), and the next pass starts again at the first entry; the pool then holds the worst of every page, as written, and an entry just stored (idle 60 s, no hits yet, the best worth there is) goes last. A test with entries arriving before every pass. I am commissioning it now on top of main's head and will land it through the usual check set. If you see the rule differently, or have this in work, say so here and I stop.

Not covered by this: the store stays 107 to 148 GB short of 15% free through all of it, since dropping a minute's puts frees about what the minute added (the readings of 11-13). Whether the same build's keys also differ from job to job when entries do stand (five tilo-actions entries of 01:31 to 03:03Z share key0 and reads_id and differ in key1) is a separate reading I have not finished.

14:20Z: the fix is on main as 8fb821de (on top of 57ef25c6). read_page hands back the size its statement asked for and a page with fewer rows ends the round (Retention::end_round); Pace is unchanged. New test a_round_of_pages_ends_at_the_newest_entry_and_the_entries_just_stored_stand (2.8 s on testing); in entries_growing_past_the_stores_room_lose_each_passs_growth the assertion r.read <= growth.max(1) became r.read == 600 + growth, since it held only while the cursor stayed at the newest entry. Check set on testing: 15 of 15 on the second run; the first failed on the 50-head range test alone (#88).

Two things the developer saw and did not touch, yours to weigh: Retention::planned lives in memory only, so the first pass after a restart counts nothing as pending and may drop again what was dropped and not yet collected; and the pass that ends a round still holds that page's just-stored entries in its pool, which go only if the excess exceeds every older candidate left.

A restart puts the cursor at the start whatever the build, so the fix shows on production only once a round has passed the newest entry, about an hour and a half after the promote: pass lines with read far above dropped, and never-used entries of the last hours standing.

15:03Z: on production. I promoted main's head 8fb821de at 15:02:34Z; it carries your 57ef25c6 (node protocol 75, job_history.launched_ms), which had been on testing since 09:24Z and not on production. Before it: both CIs green on 8fb821de; the protocol step proven on testing with jobs running, both ways (95b08710 took over 14 of 14 at 14:29Z, 8fb821de 13 of 13 at 14:36Z, none unattachable, no missing field). On production the worker (same pod) fetched the build at 15:03:12Z and said re-attached to the jobs on disk jobs=42, nothing reaped; the server leads epoch 589.

The first retention pass of the new server, 15:04:25Z: short=103619926425 pending=0 read=20000 dropped=8516 freed=103729571429. That is the planned-in-memory point above seen live: before the restart pending stood at 50 to 100 GB of the shortfall, and the first pass after it dropped the whole shortfall again from the oldest page.

Whether the fix holds on production can be read from about 16:35Z, when a round has passed the newest entry. I will add the pass lines and the standing entries by hour then.

15:50Z: the round ended at the newest entry and started again, on production. The scan read a full page every minute since the restart; at 15:49:08Z it reached the newest entry and the next pass began at the first:

15:47:05 short=15 GB pending=13 GB read=20000 dropped=2
15:48:06 short=16 GB pending=16 GB read=20000 dropped=0
15:49:08 short=16 GB pending=16 GB read=3768  dropped=0
15:50:10 short=17 GB pending=16 GB read=20000 dropped=1

On the build before, the passes after a short page read only the minute's new entries and dropped every one. The shortfall is down from 104 GB at the restart to 16 to 17 GB. The entries standing by the hour stored follow once a few hours have passed.

What it gave the page-bundle build while entries stood (after the restart, cursor at the start): two jobs found 1,431 and 1,425 of their units and compiled 14 and 20, against 1,380 found and 65 compiled in the four jobs before; the build took 647 s instead of 1,113 s.

16:05Z: an hour on, the entries stand. Since the restart the server logged 59 passes; every one read a full page of 20,000 but the one that reached the newest entry (3,768); in none that dropped anything did read equal dropped. Entries standing in entries by the hour stored:

stored in hour (UTC, 11-16) standing of them never used
16 214 204
15 13,964 11,901
14 823 0
13 11 0
12 809 0
10 1,886 0

New puts in the hour from 15:00Z were 14,698 (t_cache_puts_total{stored="new"}), so about nineteen in twenty of that hour's entries still stand an hour later, most of them not yet used; the hours 10 to 14, under the build before, kept only what had been hit within its minute. Trimmed in the same hour: 40,593, taken from full pages by worth. I will read it once more after the second round has ended.

16:35Z: two rounds on. The server logged 87 passes since the restart; the second round reached the newest entry at 16:33Z (a page of 13,301) and the pass after it read 20,000 from the first entry again; in no pass that dropped anything did read equal dropped.

stored in hour (UTC, 11-16) standing at 16:05Z never used standing at 16:35Z never used
16 214 204 6,743 6,389
15 13,964 11,901 13,308 10,101
14 823 0 822 0
09 10,395 4,692 10,395 4,692
08 35,232 27,286 13,849 11,617

So what goes now is what the rule names: the hour-15 entries lost 656 in half an hour while 1,800 more of them were used, and the never-used entries of 08:00Z, idle for eight hours, lost 15,669. New puts in the half hour to 16:30Z were 5,742, trimmed 16,084; the shortfall stands between 10 and 24 GB.

17:35Z: three rounds on, closing. (A correction to the two readings above: I had written "passes that dropped something" for what is every pass the server logged, 59 and 87; a pass that drops nothing is logged too. Corrected in place.) The server logged 145 passes since the restart; the scan reached the newest entry three times (15:49Z, 16:33Z, about 17:15Z, pages of 3,768, 13,301 and 5,803) and each time the next pass read 20,000 from the first entry; in no pass that dropped anything did read equal dropped. Since 17:20Z the store is within its room (short=0 pending=0) and the passes drop nothing.

stored in hour (UTC, 11-16) standing at 16:05Z at 16:35Z at 17:35Z never used at 17:35Z
17 484 394
16 214 6,743 6,866 4,953
15 13,964 13,308 13,304 10,087
14 823 822 822 0
09 10,395 10,395 1,705 756

The entries of the first hour after the fix stand unchanged two and a half hours later, ten thousand of them not yet used; what the store's room took meanwhile were the morning's (hour 09: 10,395 to 1,705). That is the rule the module states. Closing; the two points under 14:20Z (planned kept in memory only, and the pool at a round's end) stay yours to weigh, and I open nothing for them unasked.

Production b5c5b140, read-only readings of 13:30 to 13:57Z 11-16. Since about 09:45Z today the cache's retention pass drops, every minute, exactly the entries stored in the minute before, unless something used them meanwhile. A head cannot find what the head before it compiled. **What the pass does.** `read_page` (`src/jobs/cache/retention.rs`) reads `WHERE seq > $after ORDER BY seq LIMIT $size` and starts a new round only when a page comes back empty. With puts arriving every minute a page after the newest entry is never empty, so once the cursor has reached the newest entry it stays there: each pass reads only what was put since the last one. Earlier drops have drained the pool, so the pool is those new entries alone; their bytes do not cover the excess, and `drop_for` lets every candidate go. The pass's own lines say it, `read` equals `dropped` in every one of the 62 passes between 12:43Z and 13:47Z: ``` 13:35:51 short=107250575769 pending=38449458529 read=1202 dropped=1202 freed=13120730242 13:36:52 short=122980845977 pending=51570188771 read=641 dropped=641 freed=12360426315 13:37:53 short=132056279449 pending=63930615086 read=164 dropped=164 freed=5694278108 13:46:09 short=138016692633 pending=96788536638 read=1255 dropped=1255 freed=9629229920 ``` Sums over the 62 passes: read 39,997, dropped 43,858, freed 552 GB, mean short 125 GB. The spec's sentence it breaks is the module's own: "every entry is looked at once in each round of pages", and "worth alone decides". **What stands in `entries`, by the hour stored** (13:56Z): | stored in hour (UTC, 11-16) | standing | of them never used | |---|---|---| | 13 | 121 | 110 | | 12 | 1,070 | 0 | | 11 | 143 | 0 | | 10 | 1,888 | 0 | | 09 | 10,428 | 4,711 | | 08 | 38,580 | 30,240 | | 07 | 42,133 | 31,848 | | 06 | 43,235 | 32,419 | New puts were 12,545 to 33,511 an hour in those hours (Prometheus, `t_cache_puts_total{stored="new"}`); `t_cache_entries_dropped_total{why="trimmed"}` was 15,944 to 28,899. So from 10:00Z on about nine in ten new entries are gone within a minute, and the only survivors are those hit before the next pass (`drop_candidates` spares what was used since it was read). The same shape, hours with no never-used entry left, shows on 11-15 21:00 to 23:59Z, 11-15 01:00 to 05:59Z and 11-14 22:00Z: each time until a restart put the cursor back at the start (23:46Z 11-15; today's last was 07:56Z, and the round reached the newest entry between 09:15 and 09:45Z). **How it showed.** Four head runs in a row (jobs j587-14864, -15404, -16798, -17264) each compiled and stored the same 65 units of tilo's wasm page bundle (`m` in the jobs' own `.t-cache-counts`; 1,380 hits, 20 not stored). Between two of those heads (tilo ba938bf3b08 and 0508acbb34) four files changed, none in those crates. `entries` holds no wasm entry of `tilo-actions` at optimisation 1 stored after 09:45:07Z. That build is 18 of the 33 minutes of `test/tilo-session-client` in each head (#74). It is how I found this, not its measure: 38 of 45 heads in the last 16 hours changed a crate that build reads, and that job was as long in the hours when entries stood. What this fault costs is wider: every unit whose key changed since the cursor stuck is compiled again by each head after, in every family, because no head's entry of it stands. **What I am doing.** This restores the module's stated rule, so I take it as a fix, not a design change: a round ends when a page reaches the newest entry (a page shorter than asked), and the next pass starts again at the first entry; the pool then holds the worst of every page, as written, and an entry just stored (idle 60 s, no hits yet, the best worth there is) goes last. A test with entries arriving before every pass. I am commissioning it now on top of main's head and will land it through the usual check set. If you see the rule differently, or have this in work, say so here and I stop. Not covered by this: the store stays 107 to 148 GB short of 15% free through all of it, since dropping a minute's puts frees about what the minute added (the readings of 11-13). Whether the same build's keys also differ from job to job when entries do stand (five `tilo-actions` entries of 01:31 to 03:03Z share `key0` and `reads_id` and differ in `key1`) is a separate reading I have not finished. **14:20Z: the fix is on main as 8fb821de** (on top of 57ef25c6). `read_page` hands back the size its statement asked for and a page with fewer rows ends the round (`Retention::end_round`); `Pace` is unchanged. New test `a_round_of_pages_ends_at_the_newest_entry_and_the_entries_just_stored_stand` (2.8 s on testing); in `entries_growing_past_the_stores_room_lose_each_passs_growth` the assertion `r.read <= growth.max(1)` became `r.read == 600 + growth`, since it held only while the cursor stayed at the newest entry. Check set on testing: 15 of 15 on the second run; the first failed on the 50-head range test alone (#88). Two things the developer saw and did not touch, yours to weigh: `Retention::planned` lives in memory only, so the first pass after a restart counts nothing as pending and may drop again what was dropped and not yet collected; and the pass that ends a round still holds that page's just-stored entries in its pool, which go only if the excess exceeds every older candidate left. A restart puts the cursor at the start whatever the build, so the fix shows on production only once a round has passed the newest entry, about an hour and a half after the promote: pass lines with `read` far above `dropped`, and never-used entries of the last hours standing. **15:03Z: on production.** I promoted main's head 8fb821de at 15:02:34Z; it carries your 57ef25c6 (node protocol 75, `job_history.launched_ms`), which had been on testing since 09:24Z and not on production. Before it: both CIs green on 8fb821de; the protocol step proven on testing with jobs running, both ways (95b08710 took over 14 of 14 at 14:29Z, 8fb821de 13 of 13 at 14:36Z, none unattachable, no `missing field`). On production the worker (same pod) fetched the build at 15:03:12Z and said `re-attached to the jobs on disk jobs=42`, nothing reaped; the server leads epoch 589. The first retention pass of the new server, 15:04:25Z: `short=103619926425 pending=0 read=20000 dropped=8516 freed=103729571429`. That is the `planned`-in-memory point above seen live: before the restart `pending` stood at 50 to 100 GB of the shortfall, and the first pass after it dropped the whole shortfall again from the oldest page. Whether the fix holds on production can be read from about 16:35Z, when a round has passed the newest entry. I will add the pass lines and the standing entries by hour then. **15:50Z: the round ended at the newest entry and started again, on production.** The scan read a full page every minute since the restart; at 15:49:08Z it reached the newest entry and the next pass began at the first: ``` 15:47:05 short=15 GB pending=13 GB read=20000 dropped=2 15:48:06 short=16 GB pending=16 GB read=20000 dropped=0 15:49:08 short=16 GB pending=16 GB read=3768 dropped=0 15:50:10 short=17 GB pending=16 GB read=20000 dropped=1 ``` On the build before, the passes after a short page read only the minute's new entries and dropped every one. The shortfall is down from 104 GB at the restart to 16 to 17 GB. The entries standing by the hour stored follow once a few hours have passed. What it gave the page-bundle build while entries stood (after the restart, cursor at the start): two jobs found 1,431 and 1,425 of their units and compiled 14 and 20, against 1,380 found and 65 compiled in the four jobs before; the build took 647 s instead of 1,113 s. **16:05Z: an hour on, the entries stand.** Since the restart the server logged 59 passes; every one read a full page of 20,000 but the one that reached the newest entry (3,768); in none that dropped anything did `read` equal `dropped`. Entries standing in `entries` by the hour stored: | stored in hour (UTC, 11-16) | standing | of them never used | |---|---|---| | 16 | 214 | 204 | | 15 | 13,964 | 11,901 | | 14 | 823 | 0 | | 13 | 11 | 0 | | 12 | 809 | 0 | | 10 | 1,886 | 0 | New puts in the hour from 15:00Z were 14,698 (`t_cache_puts_total{stored="new"}`), so about nineteen in twenty of that hour's entries still stand an hour later, most of them not yet used; the hours 10 to 14, under the build before, kept only what had been hit within its minute. Trimmed in the same hour: 40,593, taken from full pages by worth. I will read it once more after the second round has ended. **16:35Z: two rounds on.** The server logged 87 passes since the restart; the second round reached the newest entry at 16:33Z (a page of 13,301) and the pass after it read 20,000 from the first entry again; in no pass that dropped anything did `read` equal `dropped`. | stored in hour (UTC, 11-16) | standing at 16:05Z | never used | standing at 16:35Z | never used | |---|---|---|---|---| | 16 | 214 | 204 | 6,743 | 6,389 | | 15 | 13,964 | 11,901 | 13,308 | 10,101 | | 14 | 823 | 0 | 822 | 0 | | 09 | 10,395 | 4,692 | 10,395 | 4,692 | | 08 | 35,232 | 27,286 | 13,849 | 11,617 | So what goes now is what the rule names: the hour-15 entries lost 656 in half an hour while 1,800 more of them were used, and the never-used entries of 08:00Z, idle for eight hours, lost 15,669. New puts in the half hour to 16:30Z were 5,742, trimmed 16,084; the shortfall stands between 10 and 24 GB. **17:35Z: three rounds on, closing.** (A correction to the two readings above: I had written "passes that dropped something" for what is every pass the server logged, 59 and 87; a pass that drops nothing is logged too. Corrected in place.) The server logged 145 passes since the restart; the scan reached the newest entry three times (15:49Z, 16:33Z, about 17:15Z, pages of 3,768, 13,301 and 5,803) and each time the next pass read 20,000 from the first entry; in no pass that dropped anything did `read` equal `dropped`. Since 17:20Z the store is within its room (`short=0 pending=0`) and the passes drop nothing. | stored in hour (UTC, 11-16) | standing at 16:05Z | at 16:35Z | at 17:35Z | never used at 17:35Z | |---|---|---|---|---| | 17 | | | 484 | 394 | | 16 | 214 | 6,743 | 6,866 | 4,953 | | 15 | 13,964 | 13,308 | 13,304 | 10,087 | | 14 | 823 | 822 | 822 | 0 | | 09 | 10,395 | 10,395 | 1,705 | 756 | The entries of the first hour after the fix stand unchanged two and a half hours later, ten thousand of them not yet used; what the store's room took meanwhile were the morning's (hour 09: 10,395 to 1,705). That is the rule the module states. Closing; the two points under 14:20Z (`planned` kept in memory only, and the pool at a round's end) stay yours to weigh, and I open nothing for them unasked.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
tilo/t#87
No description provided.