tracker
All repositories: gitoria
2.5 KB
# 044 — the background jobs run in slices (tracker.worldapi.org ticket 45, part 2 of the trkmem fix)Cause (Hybriel mission 388, trkmem): after the server listens, the background jobs rescan whole tables with `find(null, null)`(merge 74 s, adult backfill 28.5 s, details repair 19.3 s …): every scan decodes ALL rows into one array and the single-threadedserver serves no page meanwhile (loads of 19–28 s).Finding while doing it: `iterate(null, null)` is NOT streaming either — plugins/mpackdb/mpackdb.zig `find_all` reads and decodes thewhole file into one native arena in ONE call (then hands rows out one by one). So "stream instead of find" would still block forthe whole decode. The slice therefore has to be a different query: a primary-key RANGE (`range('id', from, to)`, engine`findRangeLocs`: searches the in-RAM pk index, reads only that range's rows).Work (branch w44-jobs-slices, Hybriel only, no plugin edit):1. lib/slices.hl: 256 slices by the first two hex digits of the id (ids are 16 hex chars; the bounds are inclusive, a row whose keyequals the upper bound is left to the next slice, so the slices partition ANY key set exactly); `collectStart/collectStep/collected`collect only the ids a job needs, taking slices until `TRACKER_SLICE_MS` (30 ms) is spent per timer tick.2. adult / kind / tvmaze-status / art / credits / details-repair queues (backfill.hl, credits.hl, details.hl + jobs.hl ticks): scan byslices on the 0.1 s tick; the start log line now reads "(N ms to find them, M ms of scanning in slices)".3. merge prepare (merge.hl): a phase machine over shows → watches → seasons → episodes → follows → persons, same maps/queue, the workingmaps released at the end; `mergePrepare()` answers false until built (jobs.hl mergeTick, mergeStep).4. collections prepare (collections.hl `seedPrepare`): checks table and shows by slices (timelines: a few hundred rows, one `find`).5. check: tests/jobs-dump.hl (new) + the old tree's twin through the former functions, on tests/seed-bulk.hl (≈2.9 K shows spread overall slices, duplicate groups, strays, doubled episodes, 3 non-hex ids): sorted outputs equal incl. every table after all merge steps.6. tests/slices-bench.hl: longest tick of a sliced scan vs the one block of the old scan on a big store.7. The 5 gates + check-theme.Not changed (other owner / small): lib/people.hl photoQueue (boot-path file of worker T9: 621 K `personsTable.fetch` in ONE tick —see the report), follows/watches/franchises/timelines scans (small tables, user tables), dailysync.hl moveCopiedSummaries (runs once ever).
Branches
Latest commits
- c41587d2Merge branch 'bs2' into mainTracker
- 0dd538a6|||PR BS2: finish the boot index in slices so a booting instance keeps answeringTracker
- 019d5cedMerge branch 'records-1110' into mainTracker
- f88ae8b9|||PR records: day56 toggle live, reviewTracker
- b6b3bb4dMerge branch 'ap56e' into mainTracker
- 29a26da9|||PR AP56e: guard hidden show helpers during session syncTracker
- 7c9ec236|||PR AP56e: re-vendor Hybriel set day56 (source 36ae83a8, bin c1f595a2)Tracker
- 4b54f6f9Merge branch 'records-audit' into mainTracker
- cab4a3bc|||PR records: branch audit, PR-onlyTracker
- 641e1c4cMerge branch 'records-dp71' into mainTracker
- 85a6e9f5|||PR records: DP71 checked in ChromeTracker
- f5be5f18records: gitoria PR-only planTracker
- 46a37036records: DP71 liveTracker
- 3bcb7039Status/log: DP71 in progressTracker
- 5b3a5693Log: SR1b merged via PR 2, DP71 startedTracker
- 783957c2Merge branch 'sr1-search' into mainTracker
- 792b9652README: search results come from the routeTracker
- fd8570b1|||PR search: one server exchange per keystrokeTracker
- e8f5cbcaLog: SR1 result, SR1bTracker
- 8ad275a4Log/status: tracker 68, SR1Tracker