gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit4625aa224625aa22re-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)mre4625aa22/lib/bootscan.hl

4.1 KB

  1. // lib/bootscan.hl — THE BOOT SCANS (tracker.worldapi.org#45, mission 043): ONE streamed pass per big table at start, feeding every
  2. // derived structure that needs that table, instead of one `find(null, null)` per module (each decoded the WHOLE table into one
  3. // 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
  4. // pauses those arrays caused — missions/388-trkmem-report.md in the Hybriel repo). `iterate(null, null)` hands the rows out one at a
  5. // time and frees each (but see eachRow: the plugin decodes the file into one native arena first).
  6. //
  7. // titles → catalog.hl (the public lists, genres) shows.hl (slug map) search.hl (title entries, TMDB / TVmaze ids, slugs)
  8. // shortids.hl (owners, queue) people.hl (cast photos)
  9. // episodes → catalog.hl (newest released / upcoming dates)
  10. // people → search.hl (person entries) shortids.hl people.hl (slug map, TMDB ids, /people's order)
  11. //
  12. // Every module keeps its own lazy build (ensureIndex, ensureShortIds, …) built from the SAME per-record functions used here, so a
  13. // tool that imports one module still works; project.hl calls bootScan() once before the first request. The order inside a table is
  14. // the table's, as with the old per-module scans (search entries, short id ownership and the id queue come out the same).
  15. import { now } from 'hl:time'
  16. import { showsTable, episodesTable, personsTable, noteSlugsOf, markSlugIdsBuilt } from './shows.hl'
  17. import { beginIndex, noteIndexShow, noteIndexEpisode, finishIndex } from './catalog.hl'
  18. import { indexShow, noteIndexPerson, finishSearchIndex } from './search.hl'
  19. import { loadOldShortIds, noteShortIdRow, finishShortIds } from './shortids.hl'
  20. import { noteCastProfiles, markPeopleIndexesBuilt, noteSlugOfPerson, noteTmdbOfPerson, viewEntryOf, finishPeopleView } from './people.hl'
  21. static scanned = { titles = 0 episodes = 0 people = 0 castPhotos = 0 ms = 0 }
  22. // every row of a table, one at a time (`iterate`). NOTE (mission 043, measured): the plugin's find_all decodes the whole file into
  23. // 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
  24. // 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
  25. // (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.
  26. static eachRow = (table, each) => {
  27. let n = 0
  28. for (r of table.iterate(null, null)) {
  29. each(r)
  30. n = n + 1
  31. }
  32. return n
  33. }
  34. static scanTitles = () => {
  35. t0 = now()
  36. beginIndex()
  37. loadOldShortIds()
  38. eachRow(showsTable, (&s) => {
  39. noteIndexShow(s)
  40. noteSlugsOf(s)
  41. indexShow(s)
  42. noteShortIdRow('show', s)
  43. scanned.castPhotos = scanned.castPhotos + noteCastProfiles(s)
  44. scanned.titles = scanned.titles + 1
  45. return null
  46. })
  47. markSlugIdsBuilt()
  48. console.log('boot scan: ' + scanned.titles + ' titles in ' + (now() - t0) + ' ms')
  49. return t0
  50. }
  51. static scanEpisodes = () => {
  52. t0 = now()
  53. eachRow(episodesTable, (&e) => {
  54. noteIndexEpisode(e)
  55. scanned.episodes = scanned.episodes + 1
  56. return null
  57. })
  58. finishIndex()
  59. console.log('boot scan: ' + scanned.episodes + ' episodes in ' + (now() - t0) + ' ms')
  60. return true
  61. }
  62. static peopleStored = []
  63. static scanPeople = (&t0) => {
  64. t1 = now()
  65. eachRow(personsTable, (&p) => {
  66. noteIndexPerson(p)
  67. noteShortIdRow('person', p)
  68. noteSlugOfPerson(p)
  69. noteTmdbOfPerson(p)
  70. peopleStored.push(viewEntryOf(p))
  71. scanned.people = scanned.people + 1
  72. return null
  73. })
  74. markPeopleIndexesBuilt(scanned.castPhotos)
  75. finishSearchIndex(t0)
  76. finishShortIds(t0)
  77. finishPeopleView(peopleStored)
  78. console.log('boot scan: ' + scanned.people + ' people in ' + (now() - t1) + ' ms')
  79. // tracker#37's log line (tests/browser.mjs reads it)
  80. console.log('people view: ' + scanned.people + ' people, ' + scanned.castPhotos + ' cast photos in ' + (now() - t1) + ' ms')
  81. return true
  82. }
  83. static bootScan = () => {
  84. t0 = scanTitles()
  85. scanEpisodes()
  86. scanPeople(t0)
  87. scanned.ms = now() - t0
  88. console.log('boot scan: done in ' + scanned.ms + ' ms')
  89. return scanned
  90. }

Branches

Latest commits

  • 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
  • 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