[pull] canary from vercel:canary#1133
Merged
Merged
Conversation
This is a follow-up PR to #94297 (comment); also adds an `append()` method to `BumpVec`. --------- Co-authored-by: Benjamin Woodruff <benjamin.woodruff@vercel.com>
### What? Shrink `RawVc` (16 → **8 bytes**) and `CellId` (6 → **4 bytes**), by hand-packing them into `NonZero` integers. ### Why? `RawVc` is the type-erased representation behind every `Vc` / `ResolvedVc` / `OperationVc`, and `CellId` keys every task cell. They live in huge numbers in the cache keys and task storage to track cells. Cutting `RawVc` in half and `CellId` by a third removes hundreds of megabytes of peak RSS on a real, large app. ### How? | Type | Before | After | Representation | |-----------|----------|----------|----------------| | `CellId` | 6 bytes | **4 bytes** | `NonZeroU32`: `ValueTypeId` in the top 10 bits, cell index in the low 22 bits | | `RawVc` | 16 bytes | **8 bytes** | `NonZeroU64`; bit 31 flags `LocalOutput`, and the two task variants are split by whether the high-32-bit `CellId` field is zero | Supporting changes: - **`TaskId` constrained to 31 bits** - **`ValueTypeId` capped at 1023** (10 bits) and **cell index capped at ~4.19M** (22 bits), enforced at the registry and cell-allocation sites. Together those restrictions enable us to preserve a bit to use as a discreminent in RawVc and pack `CellId` into a u32 ### Perf Building vercel-site, 5 runs each. `maxRSS` and `user CPU` are means; `wall` is the median | Condition | Branch | maxRSS | wall (s) | user CPU (s) | |---|---|---|---|---| | No persistence | canary | 13.64 GiB | 41.56 | 305.64 | | No persistence | **this PR** | **13.04 GiB** | 40.72 | 299.52 | | | | **−4.4%** | −2.0% | −2.0% | | Persistence | canary | 17.19 GiB | 55.20 | 466.54 | | Persistence | **this PR** | **16.30 GiB** | 55.12 | 462.33 | | | | **−5.2%** | −0.1% | −0.9% | <!-- NEXT_JS_LLM_PR -->
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )