gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmaind2e6d26bMerge branch 'records-park55' into mainTrackermain/reports/044-jobs-slices.md

9.1 KB

  1. # Report 044 — background jobs in slices (ticket 45, part 2) — branch w44-jobs-slices (NOT merged, NOT deployed)
  2. ## Commits (worktree /media/STORAGE/claude-scratch/atlas/T10/wt, from main 6648ba4)
  3. - 633ee21 slices.hl + adult / kind / tvmaze-status / art / credits / details-repair queues sliced
  4. - d25bd14 merge prepare + collections prepare sliced; tests/jobs-dump.hl (+ old twin), tests/seed-bulk.hl
  5. - (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
  6. - (next) 4096 slices for tables > 200 K rows, 15 ms budget, TRACKER_SLICE_DEPTH (test override)
  7. (`git log w44-jobs-slices` has the exact hashes.)
  8. ## Finding: `iterate(null, null)` is not streaming
  9. plugins/mpackdb/mpackdb.zig `find_all` (l.444) scans + decodes the WHOLE file into one native arena in one call, then hands rows out
  10. one by one. So "replace find by iterate" (merge.hl:143, backfill.hl:175 already did) still blocks for the whole decode (the report-388
  11. 5 s for episodes) and holds the decoded table natively. A real fix of the plugin (a scanner that advances per next()) is a Hybriel /
  12. plugin job (not done, no JS/no plugin edit). I slice differently, in app code: a primary-key RANGE query `range('id', from, to)`
  13. (engine `findRangeLocs`: binary search in the in-RAM index, only that range's rows are read and decoded).
  14. ## 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)
  15. | job | before | after |
  16. |---|---|---|
  17. | 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 |
  18. | kind backfill, tvmaze-status (backfill.hl) | find(null,null) | same, kindPred / statusPred |
  19. | art backfill | `iterate(null,null)` (eager) | same, artPred |
  20. | credits job (credits.hl) | find(null,null) | creditsScanStart + creditsPred |
  21. | details repair (details.hl) | find(null,null) (19.3 s) | detailsRepairScan + repairClass (1 = reduced first, 2 = rest; queue = first then rest, as before) |
  22. | 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 |
  23. | 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 |
  24. 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.
  25. 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; a
  26. row whose key equals the upper bound is left to the next slice → exact partition of ANY key set (fixture has 'tmdb-zz1', 'Zed', '0').
  27. ## Same output (tests/jobs-dump.hl vs tests/jobs-dump-old.hl in a checkout of main; cmp.sh in evidence)
  28. Fixture tests/seed-bulk.hl (2,879 shows, 2,866 seasons, 3,973 episodes, 843 watches, 273 follows, 231 persons; 120 duplicate groups with
  29. moved/merged seasons+episodes, follows, watches; doubled episodes; stray seasons; non-hex ids; deterministic ids, two fresh stores).
  30. Dumps every job queue (adult 1803, kind 1561, status 230, art 600, credits 133, repair 1803, collections seed 802) + the merge prepare stats
  31. + (merge=1) all tables after ALL merge steps ran; `sort`ed (slices = key order, old scans = file order), `mergedAt` timestamps and the
  32. two timing log lines removed: **IDENTICAL** for merge=0, merge=1, and merge=1 with TRACKER_SLICE_DEPTH=3 (merge totals: groups=120
  33. tombstones=120 follows=6 watches=11 seasonsMoved=48 seasonsMerged=60 episodesMoved=12 episodesMerged=80).
  34. Not covered by the dump (known): strayTitles stays 0 on the fixture (gate seed-dupes covers strays via the browser gate).
  35. **One behavioural difference, deliberate:** pickKeeper's last tie-break "equal → the first" meant the first in FILE order; a group's ids now come
  36. in 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 my
  37. first fixture produced different keepers (found, then fixed the fixture to give distinct ages). Migrated rows have Mongo oldIds, so the real
  38. data should not tie; if exact file order must be kept the plugin has to expose offsets (Hybriel gap).
  39. 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 a
  40. later slice or not, as it was for writes after the old prepare (the maps are not re-read after the build either way).
  41. ## Tick length (tests/slices-bench.hl, 62 K-title synthetic store, machine load 14–20, evidence bench-62k.txt)
  42. 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;
  43. 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 live
  44. objects), 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
  45. (16 M live objects) — that is the boot/T9 + runtime part, not the jobs'.
  46. ## 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.
  47. (The gates run the sliced jobs: backfill / repair / status / kinds / art / credits / merge / collections are on in them. The first gate run, before the
  48. `mergeLeft` import was added, failed at server start "not yet compilable: call to 'mergeLeft'" — so the gates do fail on a broken job path.)
  49. No UI change → no screenshots.
  50. ## NOT done / for others
  51. - 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) in
  52. ONE tick of photoTick → minutes of blocked event loop; needs the same slicing (needsPhoto uses castProfiles + photoUrlOf — iterate peopleView.ids in
  53. chunks of ~200 per tick; no table scan needed). Not touched (T9 owns people.hl).
  54. - plugin: a real streaming `find_all` (Scanner advanced per next()) would let every scan use `iterate(null,null)` (and kill the native arena of the
  55. whole table) — Hybriel/plugin task. Also `deletedSet` is rebuilt for every range call; with real tombstone counts the per-slice overhead has to be
  56. measured (below).
  57. - follows.hl:19/49, watches.hl:25/64 scan whole user tables per request/sync (small; `find('user', …)` needs an index): separate ticket.
  58. - franchises.hl / franchiseseed.hl timelines scans (hundreds of rows), dailysync.hl:234 (runs once ever): left.
  59. ## Real-data measurement — THE NEXT STEP, after T9 reports (no real-data server was started by me)
  60. 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
  61. (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.
  62. 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
  63. (fake TMDB from tests/faketmdb.mjs or no token: then the TMDB jobs are off but merge + shortids run) with jobs ON:
  64. TRACKER_MERGE, TRACKER_BACKFILL, TRACKER_REPAIR, TRACKER_KINDS, TRACKER_CREDITS, TRACKER_COLLECTIONS, TRACKER_ART (unset = on; need TMDB_READ_TOKEN + TMDB_BASE_URL → fake).
  65. 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`
  66. (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).
  67. 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 = the
  68. blocked 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.
  69. 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 and
  70. are 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
  71. (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
  72. (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).
  73. ## Cleanup
  74. Own 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