tracker
All repositories: gitoria
9.1 KB
# Report 044 — background jobs in slices (ticket 45, part 2) — branch w44-jobs-slices (NOT merged, NOT deployed)## Commits (worktree /media/STORAGE/claude-scratch/atlas/T10/wt, from main 6648ba4)- 633ee21 slices.hl + adult / kind / tvmaze-status / art / credits / details-repair queues sliced- d25bd14 merge prepare + collections prepare sliced; tests/jobs-dump.hl (+ old twin), tests/seed-bulk.hl- (next) jobs.hl imports `mergeLeft` (the gates found the miss: first gate run did not start the server — proof the gates can fail), mission file, tests/slices-bench.hl- (next) 4096 slices for tables > 200 K rows, 15 ms budget, TRACKER_SLICE_DEPTH (test override)(`git log w44-jobs-slices` has the exact hashes.)## Finding: `iterate(null, null)` is not streamingplugins/mpackdb/mpackdb.zig `find_all` (l.444) scans + decodes the WHOLE file into one native arena in one call, then hands rows outone by one. So "replace find by iterate" (merge.hl:143, backfill.hl:175 already did) still blocks for the whole decode (the report-3885 s for episodes) and holds the decoded table natively. A real fix of the plugin (a scanner that advances per next()) is a Hybriel /plugin job (not done, no JS/no plugin edit). I slice differently, in app code: a primary-key RANGE query `range('id', from, to)`(engine `findRangeLocs`: binary search in the in-RAM index, only that range's rows are read and decoded).## What changed, per job (all: scan on the job's 0.1 s timer tick, `TRACKER_SLICE_MS` = 15 ms of slices per tick, then the event loop serves pages)| job | before | after ||---|---|---|| adult backfill (backfill.hl, jobs.hl backfillTick) | `showsTable.find(null,null)` → 106 K rows in one block (28.5 s on real data) | `collectStep(scan, adultPred)`: only ids kept, 256 slices || kind backfill, tvmaze-status (backfill.hl) | find(null,null) | same, kindPred / statusPred || art backfill | `iterate(null,null)` (eager) | same, artPred || credits job (credits.hl) | find(null,null) | creditsScanStart + creditsPred || details repair (details.hl) | find(null,null) (19.3 s) | detailsRepairScan + repairClass (1 = reduced first, 2 = rest; queue = first then rest, as before) || merge prepare (merge.hl; 74 s on real data: shows, watches, seasons, episodes(iterate), follows, persons) | 6 whole-table passes in one call | phase machine, one table at a time in slices; `mergePrepare()` returns false until built (mergeTick / mergeStep updated); working maps in `prep`, released at the end || collections prepare (collections.hl) | checks + timelines + shows find | checks and shows sliced, timelines (hundreds of rows) one find; `seedPrepare()` returns bool; seedStep waits for it |Start log lines now say "(N ms to find them, M ms of scanning in S slices)" — N is wall time over the ticks, M the scan work.Slices: 256 (2 hex digits of the id) or 4096 (3 digits) for a table > 200 K rows (persons 621 K, episodes 1.4 M). Bounds are inclusive; arow whose key equals the upper bound is left to the next slice → exact partition of ANY key set (fixture has 'tmdb-zz1', 'Zed', '0').## Same output (tests/jobs-dump.hl vs tests/jobs-dump-old.hl in a checkout of main; cmp.sh in evidence)Fixture tests/seed-bulk.hl (2,879 shows, 2,866 seasons, 3,973 episodes, 843 watches, 273 follows, 231 persons; 120 duplicate groups withmoved/merged seasons+episodes, follows, watches; doubled episodes; stray seasons; non-hex ids; deterministic ids, two fresh stores).Dumps every job queue (adult 1803, kind 1561, status 230, art 600, credits 133, repair 1803, collections seed 802) + the merge prepare stats+ (merge=1) all tables after ALL merge steps ran; `sort`ed (slices = key order, old scans = file order), `mergedAt` timestamps and thetwo timing log lines removed: **IDENTICAL** for merge=0, merge=1, and merge=1 with TRACKER_SLICE_DEPTH=3 (merge totals: groups=120tombstones=120 follows=6 watches=11 seasonsMoved=48 seasonsMerged=60 episodesMoved=12 episodesMerged=80).Not covered by the dump (known): strayTitles stays 0 on the fixture (gate seed-dupes covers strays via the browser gate).**One behavioural difference, deliberate:** pickKeeper's last tie-break "equal → the first" meant the first in FILE order; a group's ids now comein key order. It only matters when two duplicates tie on user data, old short id AND age (no 24-hex oldId / `imported`) — with such ties myfirst fixture produced different keepers (found, then fixed the fixture to give distinct ages). Migrated rows have Mongo oldIds, so the realdata should not tie; if exact file order must be kept the plugin has to expose offsets (Hybriel gap).Also: the merge prepare now spans ~minutes of wall time instead of one atomic call; a watch/follow the user writes during the scan is read by alater slice or not, as it was for writes after the old prepare (the maps are not re-read after the build either way).## Tick length (tests/slices-bench.hl, 62 K-title synthetic store, machine load 14–20, evidence bench-62k.txt)old `find(null,null)` of shows: ONE block 650–990 ms (real data: 28 s / 74 s). New: adult scan 30–81 ticks, merge prepare 84–195 ticks;longest tick 89–174 ms with a 15 ms budget — the outliers are runtime GC pauses (HL_GC_STATS: 80–104 ms collections with 0.4 M liveobjects), not the slices (a slice is 250 rows ≈ 1–3 ms; per-slice overhead ~3 ms at depth 3). On the real data GC pauses of seconds remain(16 M live objects) — that is the boot/T9 + runtime part, not the jobs'.## Gates (own ports 8752–8758, wt, after the mergeLeft fix): browser 382/0, kinds 32/0, franchises 53/0, pager 229/0, franchiseseed 26/0, check-theme 95 files 0 problems = old counts. Logs /media/STORAGE/claude-scratch/atlas-evidence/T10/gate-new-*.log, gates-new.log.(The gates run the sliced jobs: backfill / repair / status / kinds / art / credits / merge / collections are on in them. The first gate run, before the`mergeLeft` import was added, failed at server start "not yet compilable: call to 'mergeLeft'" — so the gates do fail on a broken job path.)No UI change → no screenshots.## NOT done / for others- lib/people.hl `photoQueue` (T9's file): after the people view is built it does `personsTable.fetch(id)` for every id of peopleView (621 K) inONE tick of photoTick → minutes of blocked event loop; needs the same slicing (needsPhoto uses castProfiles + photoUrlOf — iterate peopleView.ids inchunks of ~200 per tick; no table scan needed). Not touched (T9 owns people.hl).- plugin: a real streaming `find_all` (Scanner advanced per next()) would let every scan use `iterate(null,null)` (and kill the native arena of thewhole table) — Hybriel/plugin task. Also `deletedSet` is rebuilt for every range call; with real tombstone counts the per-slice overhead has to bemeasured (below).- follows.hl:19/49, watches.hl:25/64 scan whole user tables per request/sync (small; `find('user', …)` needs an index): separate ticket.- franchises.hl / franchiseseed.hl timelines scans (hundreds of rows), dailysync.hl:234 (runs once ever): left.## Real-data measurement — THE NEXT STEP, after T9 reports (no real-data server was started by me)Setup (on loreana, own scratch, ONE tracker at a time, ≥ 25 GB free): copy of the newest /media/STORAGE/deploy-backups/tracker.worldapi.org/*.tgz(untar; a tar copy is fine, the store is read by a fresh process), az5b2 session in the copy, TRACKER_WATCH=0, HL_GC_STATS=1, no .env.Run twice with the SAME storage backup (untar anew): (a) `git worktree` of main 6648ba4 (old), (b) branch w44-jobs-slices. Env as the kinds gate(fake TMDB from tests/faketmdb.mjs or no token: then the TMDB jobs are off but merge + shortids run) with jobs ON:TRACKER_MERGE, TRACKER_BACKFILL, TRACKER_REPAIR, TRACKER_KINDS, TRACKER_CREDITS, TRACKER_COLLECTIONS, TRACKER_ART (unset = on; need TMDB_READ_TOKEN + TMDB_BASE_URL → fake).1. Wait for "listening". From that moment: `while sleep 0.5; do curl -s -o /dev/null -w "%{time_starttransfer} %{http_code}\n" http://127.0.0.1:<port>/series/<slug>; done > ttfb-<old|new>.txt`(a /series/<slug> page, plus /, /movies; ~every 0.5 s for the first 5 minutes — the jobs' start window) and 100 loads of 5 slugs afterwards (as report 388 §3).2. From the app log: lines `merge: start … (N ms to find them)`, `adult backfill: start …`, `details repair: start …`, `kind backfill`, `credits job`, `art backfill`, `collections: start` (old: N = theblocked scan, 74252 / 28534 / 19286 ms; new: N = wall time over ticks + "M ms of scanning in S slices") and `[hl-gc]` pause_ms around them.3. Compare: p50/p95/max TTFB during the first 5 min (target: no page > ~100 ms longer because of a job; GC pauses of the boot-sized heap remain andare T9/runtime), job durations, RSS (VmHWM), GC pause sum. Extra for the per-slice cost: run tests/slices-bench.hl against the copy's storage(app STOPPED): `TRACKER_STORAGE=<copy>/mpackdb ./bin/hybriel tests/slices-bench.hl` → longest tick of the adult scan and of mergePrepare on the real tables(watch the deletedSet cost per range call with the real tombstone counts; if a slice costs > ~20 ms, raise TRACKER_SLICE_DEPTH or lower the budget).## CleanupOwn processes ended (gates, seed), ports 8752–8764 empty, `git worktree remove` of T10/old after the report; fixtures/stores in T10/fx.
Branches
Latest commits
- d2e6d26bMerge branch 'records-park55' into mainTracker
- f567f025|||PR records: park #55, no Claude workers ruleTracker
- c21aff6bMerge branch 'records-hm55c' into mainTracker
- 9ba258d3|||PR records: HM55b resultTracker
- 64f2d300Merge branch 'records-hm55b2' into mainTracker
- ae3b80dc|||PR records: HM55b briefTracker
- 7ef3cb3bMerge branch 'records-st55' into mainTracker
- fec2e080|||PR records: STATUS HM55Tracker
- 8e174918Merge branch 'records-hm55b' into mainTracker
- b1ecee57|||PR records: HM55 stateTracker
- 28eab08cMerge branch 'records-hm55' into mainTracker
- d3edaa05|||PR records: HM55 start, PROCEDURES.mdTracker
- 3059f86cMerge branch 'records-design-rule' into mainTracker
- 421a4809|||PR records: his-design rule (Apollo 2026-11-13)Tracker
- d1390692Merge branch 'records-dp75b' into mainTracker
- a4d1a7d2|||PR records: later steps checked, branch auditTracker
- e070e16fMerge branch 'records-dp75' into mainTracker
- 642b4fa8|||PR records: DP75 day62 live, AP62 briefTracker
- bfc4ea4dMerge branch 'ap62' into mainTracker
- 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker