Skip to content

Improve the tbdocs build performance. - #274

Merged
KubaO merged 18 commits into
twinbasic:mainfrom
KubaO:staging
Nov 18, 2026
Merged

KubaO merged 18 commits into
twinbasic:mainfrom
KubaO:staging

Conversation

@KubaO

@KubaO KubaO commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator
  • Lane tasks, not threads: the search index and the help archive run as lane tasks (fanOut) instead of on threads of their own, and search-index-worker.mjs is gone. The archive is deflated while the index is built, and a large file in 1 MB pieces, each primed with the 32 KB before it. A new lint rule keeps it so: no task of the build starts a thread, and builder/ and lib/ import only zlib's Sync functions, by name.
  • More work on the lanes: packTests runs on a lane, and no page waits for it but those that state a packed file's size (their render chunks wait for downloadSizes). The render lanes do the per-page part of the symbol index and the search entries and pack the entries for search-data.json and the index's lanes, so symbolPlace, searchEntries and indexSlices are all that is left between the last chunk and the first indexAdd.
  • Source tree: read in pieces on the lanes (discoverList, discoverRead:i, discover): two pieces, or four on a machine with eight or more CPUs, which a lane takes after the first stage of its boot. The lanes pack their pages' text into a shared buffer (packPageText), so a render chunk's payload names where each page's text is instead of holding it.
  • dispatch: the offline_exclude patterns are compiled once for each list (builder/fnmatch.mjs), which was most of it (about 0.6 s on CI before, about 0.1 s after). It no longer waits for buildInfo, which only the book's title page reads (bookPayload waits for it).
  • Smaller costs: findCountRefs cuts into code spans only the lines that hold a placeholder, maskCode finds line ends and backticks without reading each character, and the package tests' folders are listed once. computeNav sorts each page's children once, for the tree, the levels and the children list, and its walk carries the levels.
  • Tests and docs: test/discover.test.mjs is new (the inventory in any number of pieces, matchesAny, computeNav) and runs in test.bat and CI; the search, search-index, render and add-in project tests follow the changes. Pipeline Stages, tbdocs Internals, WIP.Build.md, WIP.Search.md and the scheduler diagram describe each task and what it gained.

KubaO added 18 commits November 17, 2026 20:37
…ut), not on threads of their own; the archive is deflated while the index is built, and a large file in primed 1 MB pieces
…hat state a packed file's size, whose render chunks wait for downloadSizes
… the search entries, and pack the entries for search-data.json and the index's lanes; symbolPlace, searchEntries and indexSlices are what is left between the last chunk and the first indexAdd
…tries, and what the lanes wait for after the last render chunk
…ist, discoverRead:i, discover), which take a piece after the first stage of their boot; test/discover.test.mjs
…t, and what reading the source tree on the lanes gained
…(builder/fnmatch.mjs), which was most of dispatch; its tests in test/discover.test.mjs
…uffer (packPageText), and a render chunk's payload names where each page's text is instead of holding it
… placeholder, maskCode finds line ends and backticks without reading each character, and the package tests' folders are listed once
…levels and the children list, and the walk carries the levels; its tests in test/discover.test.mjs
…itle page reads (bookPayload waits for it), and the source tree is read in four pieces on a machine with eight or more CPUs
@KubaO
KubaO merged commit 640a397 into twinbasic:main Nov 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant