Repository navigation
perf(storage): stop forcing a full GC after every part - #9
Open
chenrui333 wants to merge 1 commit into
Open
chenrui333 wants to merge 1 commit into
chenrui333 wants to merge 1 commit into
Conversation
`streamParts()` awaited `globalThis.gc()` after every part, and the image starts Node with `--expose-gc`, so every part of every unmerged restore and streaming merge ran a synchronous full mark-compact on the event loop. With ~1 MiB parts (BuildKit) that caps all concurrent first restores combined at roughly one part per GC pause, and the pause grows with the heap, so more concurrent restores make every one of them slower. Memory no longer depends on it: the upload route lets storage pace the body (falcondev-oss#275) and the download route pipes with backpressure (falcondev-oss#282), so the bytes in flight are bounded by stream high-water marks and become ordinary garbage that V8 collects incrementally. Remove both calls, the `--expose-gc` flag and the startup warning about it. Signed-off-by: Rui Chen <rui@chenrui.dev>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Owner
Author
|
@codex review |
1 similar comment
Owner
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
streamParts()awaitsglobalThis.gc()after every part,pumpPartsToStreams()once more at the end, and the image starts Node with--expose-gc. Every part of every unmerged restore and streaming merge therefore runs a synchronous full mark-compact on the event loop. With BuildKit's ~1 MiB parts that caps all concurrent first restores combined at roughly one part per GC pause, and the pause grows with the heap, so more concurrent restores make each of them slower.The calls were added for memory (falcondev-oss#182), but memory no longer depends on them: the upload route lets storage pace the body (falcondev-oss#275) and the download route pipes with backpressure (falcondev-oss#282). The bytes in flight are bounded by stream high-water marks and become ordinary garbage that V8 collects incrementally.
This PR removes both calls, the
--expose-gcflag and the startup warning that asked for it.Benchmark
Built
dev(nitropack build), one worker, SQLite + filesystem, on an M-series Mac. Each run seeds N unmerged entries of 96 × 1 MiB parts, then restores all of them concurrently (first restore = tee + merge), then again after the merges (warm). Every restore is SHA-256 checked (all passed). Peak RSS is the max over the primary and worker processes, sampled every 200 ms. Interleaved runs:dev,--expose-gc(as shipped)dev,--expose-gcRunning
devwithout--expose-gc(soglobalThis.gcis undefined) matched this PR: 2.0 / 3.2 / 2.7 s at N = 16. Warm (merged) restores don't callgc()and were the same for both builds (~1 GiB/s).Memory stays bounded without forced GC: peak RSS is ~350 MiB at both 16 and 32 concurrent restores, about 50 MiB above the forced-GC build, and does not grow with concurrency.
pnpm test:run(sqlite + filesystem) passes as ondev;type-checkand eslint are clean.Notes
--expose-gckeep working; the flag simply has no caller any more.