Repository navigation
Conversation
Compiled partials keep the template context until the next build, and the `$assets` of that context was made inside `run()`, so its closures kept the whole scope of `run()` alive: in dev on the 10k-page bench, the HTML of every page twice, ~420 MB. `$assets` now comes from a factory outside `run()` that keeps only the assets folder, the render context, and the base path. `templates.collect` also starts from empty caches, so a partial or layout that is gone keeps nothing alive, and no stale block stays. Closes #59
`bun run bench dev` runs `bongo dev` on the generated site: the first build, 3 full rebuilds from a layout edit, and 3 page edits. For each, it reports the time that dev logs, the RSS during it and after it, and the footprint and JS heap that dev reports once it settles. On macOS, RSS also counts memory that the allocator freed until the system takes it back, so the footprint is the number to watch.
On the 10k-page bench, the JS heap of dev kept ~400 MB of garbage from each rebuild, so its footprint swung between 460 MB and 1.46 GB. Dev now runs a full collection after each rebuild, in a new task: in the same task, a frame of the build still pins its objects on the stack, which JSC scans. The footprint now settles at ~138 MB and the JS heap at ~131 MB, and rebuilds take the same time.
The retention test measured the heap in the test process. After a long test run, JSC's conservative stack scan found a stale pointer to the scope of `run()` and kept the build alive, so the test failed only in the full suite. It now builds in a new `bun` process, where the stack is shallow, and runs each GC in a new task.
lukeed
added a commit
that referenced
this pull request
Oct 17, 2026
Full builds, docs, a new table of bongo build after each kind of edit, and dev with the new steps, next to #68 on the same steps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #59. Stacked on #67.
bongo devon a large site kept far more memory than its output needs. On the 10,000-page bench, its footprint swung between 460 MB and 1.46 GB, and its RSS grew by ~1 GB with each of the first full rebuilds.$assetsof that context was made insiderun(), so its closures kept the whole scope ofrun(). In dev, that held the HTML of every page twice: about 420 MB.$assetsnow comes from a factory outsiderun(), which keeps only the assets folder, the render context, and the base path.templates.collectnow starts from empty caches, so a partial or layout that is gone keeps nothing alive, and no stale block stays.bun run bench devrunsbongo devon the generated site through a small runner: the first build, 3 full rebuilds from a layout edit, and 3 page edits. For each step it reports the time that dev logs, RSS, and the footprint and JS heap once dev settles. On macOS, RSS also counts memory that the allocator freed until the system takes it back. The footprint, as Activity Monitor shows it, is the number to watch.Benchmark
bun run bench devon an M1 Max with Bun 1.4.3: #63 against this PR.RSS after the last step: 2.79 GB → 1.49 GB. A full rebuild still takes 1.8 s, and a page edit about 0.8 s.
Tests: 2 new tests. One checks that a dev build of 200 large pages keeps none of them once it returns: with the old
build.ts, it keeps 17.8 MB. The other checks thatcollectkeeps nothing of a deleted partial or layout. All 808 pass,tsc -p .andtsc -p buildare clean, andbun run buildpasses.Also in this PR
test: subprocess heap check: on top of perf: write over public/ #67, the retention test failed in the full suite, though the build kept nothing. After a long test run, JSC's conservative stack scan found a stale pointer to the scope ofrun()in the test process. The test now builds in a newbunprocess.docs: bench results:bench/results.mdrecords the bench numbers of the baseline and of each PR from perf: stream page writes #63 to fix: free the last build #68, measured with the same bench in one session, so later changes can be compared against them.