tracker
All repositories: gitoria
4.1 KB
// lib/bootscan.hl — THE BOOT SCANS (tracker.worldapi.org#45, mission 043): ONE streamed pass per big table at start, feeding every// derived structure that needs that table, instead of one `find(null, null)` per module (each decoded the WHOLE table into one// array: persons 621 K rows 11 s and 5.6 GB, episodes 1.4 M rows 9 s and +3 GB, five times over; 54 % of the boot was the GC// pauses those arrays caused — missions/388-trkmem-report.md in the Hybriel repo). `iterate(null, null)` hands the rows out one at a// time and frees each (but see eachRow: the plugin decodes the file into one native arena first).//// titles → catalog.hl (the public lists, genres) shows.hl (slug map) search.hl (title entries, TMDB / TVmaze ids, slugs)// shortids.hl (owners, queue) people.hl (cast photos)// episodes → catalog.hl (newest released / upcoming dates)// people → search.hl (person entries) shortids.hl people.hl (slug map, TMDB ids, /people's order)//// Every module keeps its own lazy build (ensureIndex, ensureShortIds, …) built from the SAME per-record functions used here, so a// tool that imports one module still works; project.hl calls bootScan() once before the first request. The order inside a table is// the table's, as with the old per-module scans (search entries, short id ownership and the id queue come out the same).import { now } from 'hl:time'import { showsTable, episodesTable, personsTable, noteSlugsOf, markSlugIdsBuilt } from './shows.hl'import { beginIndex, noteIndexShow, noteIndexEpisode, finishIndex } from './catalog.hl'import { indexShow, noteIndexPerson, finishSearchIndex } from './search.hl'import { loadOldShortIds, noteShortIdRow, finishShortIds } from './shortids.hl'import { noteCastProfiles, markPeopleIndexesBuilt, noteSlugOfPerson, noteTmdbOfPerson, viewEntryOf, finishPeopleView } from './people.hl'static scanned = { titles = 0 episodes = 0 people = 0 castPhotos = 0 ms = 0 }// every row of a table, one at a time (`iterate`). NOTE (mission 043, measured): the plugin's find_all decodes the whole file into// ONE native arena before the first row, so the PEAK is still the table's decoded size, freed after the pass. The primary-key SLICES of// mission 044 (slices.hl, `range('id', lo, hi)`) were tried here: on the copy they made the title pass 114 s and the episode pass 141 s// (iterate: 31 s / 30 s) and the person pass failed with "reading 'id': the value is Number" (slices.hl:40) — not used; see the report.static eachRow = (table, each) => {let n = 0for (r of table.iterate(null, null)) {each(r)n = n + 1}return n}static scanTitles = () => {t0 = now()beginIndex()loadOldShortIds()eachRow(showsTable, (&s) => {noteIndexShow(s)noteSlugsOf(s)indexShow(s)noteShortIdRow('show', s)scanned.castPhotos = scanned.castPhotos + noteCastProfiles(s)scanned.titles = scanned.titles + 1return null})markSlugIdsBuilt()console.log('boot scan: ' + scanned.titles + ' titles in ' + (now() - t0) + ' ms')return t0}static scanEpisodes = () => {t0 = now()eachRow(episodesTable, (&e) => {noteIndexEpisode(e)scanned.episodes = scanned.episodes + 1return null})finishIndex()console.log('boot scan: ' + scanned.episodes + ' episodes in ' + (now() - t0) + ' ms')return true}static peopleStored = []static scanPeople = (&t0) => {t1 = now()eachRow(personsTable, (&p) => {noteIndexPerson(p)noteShortIdRow('person', p)noteSlugOfPerson(p)noteTmdbOfPerson(p)peopleStored.push(viewEntryOf(p))scanned.people = scanned.people + 1return null})markPeopleIndexesBuilt(scanned.castPhotos)finishSearchIndex(t0)finishShortIds(t0)finishPeopleView(peopleStored)console.log('boot scan: ' + scanned.people + ' people in ' + (now() - t1) + ' ms')// tracker#37's log line (tests/browser.mjs reads it)console.log('people view: ' + scanned.people + ' people, ' + scanned.castPhotos + ' cast photos in ' + (now() - t1) + ' ms')return true}static bootScan = () => {t0 = scanTitles()scanEpisodes()scanPeople(t0)scanned.ms = now() - t0console.log('boot scan: done in ' + scanned.ms + ' ms')return scanned}
Branches
Latest commits
- f57f64f0mission 046: report, LOGmre
- efe1b485mission 046: re-vendor Hybriel master 60b2817b (integration 8, #203): plugins mpackdb + web (bin/ git-ignored: hybriel, libhlrt.a, hlc.o, hlrt/ from native/zig-out)mre
- 53099ffbmission 046: person page reads a slim per-title credit row cache (no whole-record fetch per credit); gate tests/person-lookup.mjsmre
- 9b3828aemission 046a: report, LOGmre
- 4b37356emission 046: franchise seed supersedeCollections reads the curated timelines once (10 s one-tick block at the end of boot)mre
- ac6268e3mission 046a: re-vendor Hybriel 528bc89f (integration 6): plugins mpackdb/time/web (bin/ git-ignored)mre
- 322b3293mission 046: photoQueue guard for non-row fetch results (damaged persons index)mre
- e5b99aecmission 046: photoQueue in slices (people.hl photoQueueStart/Step, jobs.hl photoTick), tests/photoqueue.hlmre
- 31dcf2admission 045: report, LOGmre
- 9c3971d0tests/persons-skip-count.hlmre
- 4d72e365mission 045mre
- b9cae4c9slices: skip and count non-row values from range(); merge persons pass falls back to iterate; guard testmre
- 3db7dc31merge w44-jobs-slices into w43-trkmemmre
- 593dab6fmission 043: report, LOGmre
- 1a5a4818boot scans back to iterate (slices measured slower: titles 114 s, episodes 141 s, persons failed); lambda per rowmre
- 03d29893boot scans read primary-key slices (lib/slices.hl from mission 044): iterate is eager too; people view log line back; allShows/allEpisodes stay for toolsmre
- 23375c58mission 044: report, LOG, STATUSmre
- c6fd928emission 044: 4096 slices for tables over 200 K rows, 15 ms budget, TRACKER_SLICE_DEPTH for testsmre
- fb057680mission 044: jobs.hl imports mergeLeft (gate found it), mission file, slices benchmre
- 0d6293ebmission 043: mission filemre