Give hot dumped types one-letter serde names #922
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 631 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.386
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #922"
general
weight: 0.35
rewitt94
Should also be improved by https://github.com/twittner/minicbor/pull/73
Session dumps are CBOR maps keyed by field and variant name, so key strings are most of a dump.
Measured on two sessions, key strings were 76% of a 500-snippet, 250-function REPL session and 69% of a session holding 2,000 small dicts.
The worst offenders are types written once per value, heap entry or location: every
Valuewrote its variant name (InternStringis 13 bytes around a 1–3 byte id), every heap entryrefcount/color/data, every dict itemkey/value/hash.This renames every field and variant of those types to one upper-case letter (first letter of the name, else the next unused letter in it, else the first unused letter of the alphabet):
Value,HeapEntry,CcColor,List,Tuple,Dict(its hand-written impl),DictEntry,SetEntry,CodeRange,LocationEntryandCodeLoc.Everything else keeps readable names; per-function and one-off types are a small share of a dump.
Notes for review:
HeapEntryandCcColorare inheap/mod.rs; the change there is serde attributes only.CodeLocis public inmonty-types, so its serde shape for hosts becomes{"L": …, "C": …}.HeapDatavariants are not renamed:heap_payloads!forwards variant attributes toHeapReadOutput, which has no serde derive.dump_v13.binis regenerated (18.7 KB → 12.3 KB).CLAUDE.mdrecords the convention: a new field or variant on these types takes an unused letter.SuspendPositiontocode.rs; it should get the same treatment once both land.Measured with these renames applied on top of #909:
| | before | after |
|---|---|---|
| 2,000-dict session dump | 817 KB | 407 KB |
| 500-snippet session dump | 322 KB | 211 KB |
|
session_load(local criterion) | 588 µs | 541 µs (−8.6%) ||
session_dump(local criterion) | 145.6 µs | 149.0 µs (noise) |On CodSpeed most of
session_dump's cost was glibcrealloccopying the growing buffer, which the local macOS run does not show, so CodSpeed is the better measure of dump time.🤖 Generated with Claude Code
https://claude.ai/code/session_01DFJ9rUjXVHCtQpxhZvoiGb
<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Shrinks session dumps by renaming serde fields and variants on frequently written types to single upper-case letters. Key strings were ~70% of dump size; this halves it (817 KB → 407 KB for a 2,000-dict session, 322 KB → 211 KB for a 500-snippet session) while load time drops roughly 8% and dump time is unchanged.
Notes
Value,HeapEntry,CcColor,List,Tuple,Dict,DictEntry,SetEntry,CodeRange,LocationEntry,CodeLoc,Function,Signature,Identifier,NameScope,Code,ExceptionEntry,SerializedFrame,Instance,Closure,FunctionDefaults, and the hotHeapDatavariants; all other types keep readable names.CodeLocis public inmonty-types, so its host-facing serde shape becomes{"L": …, "C": …}.dump_v13.binis regenerated.HeapReadOutputno longer repeats the registry's serde attributes, since they cannot apply to it; the registry's "append-only" notes are dropped since CBOR tags variants by name, not position.dump_rejects_transient_gc_colorswas updated to forge the now one-letterC/Bkeys instead of the old text keys.xfailcases whose expected failure must come from the run itself; mount-fs suspensions also round-trip so open files pass through the dump format.random.Random) and now suspends inside anexec()frame with a globals dict,finally,except, and__init__; regenerating it asserts the suspension landed onhost_call.slice.indices()is documented as unimplemented.CLAUDE.mddocuments the convention: new fields or variants on these types take an unused letter.<sup>Written for commit 4a5294f7bf0e83d048aafc76da73aecc1565e3fd. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/922?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->