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
- 1f9c8bf4re-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
- c1df88eddocker-compose: HL_GC_TABLE_LOAD=62 (tracker mission 048, T16 real-data numbers)mre
- d0a82867mission 048: report, LOG (HL_GC_TABLE_LOAD=62 measured)mre
- 2d4be66fre-vendor Hybriel 5df4eb7e (GC: HL_GC_TABLE_LOAD knob, mission 406)mre
- 99e7c8b9tests: realdata-m035-radii, repro-t38, realdata-060-backfill ports from env (REAL_PORT, REAL_CHROME, REPRO_CHROME), defaults unchangedmre
- 4625aa22re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- a6dfd6ecdeploy: person-lookup gate (tracker#46)mre
- 33ad4bd5Merge commit 'f57f64f'mre
- 7d38cec4docker-compose: nofile 65536 (default soft 1024 refused boot: errno 24 in fs.listDir, Hybriel 528bc89f)mre
- f57f64f0mission 046: report, LOGmre
- 5965963adeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- 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