Cap the typed-structure dictionary in RecordEncoder (maxOwnStructures) - #1145
Merged
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Contributor
|
Reviewed; no blockers found. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
kriszyp
force-pushed
the
kris/maxownstructures-cap
branch
from
June 8, 2026 12:10
af1333d to
3607b98
Compare
The per-encoder typedStructs dictionary (structon's random-access typed structs) is append-only and pinned on the long-lived primary store. A wide/sparse schema whose records vary by per-field value width mints a distinct structure per shape×width combination and grows the dictionary unbounded, exhausting memory (observed on a bulk-loaded table under replication catch-up). Default maxOwnStructures to 256 (caller-overridable), bounding each dictionary. Bumps structon to ^1.0.6, which adds the cap (uncapped by default). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
kriszyp
force-pushed
the
kris/maxownstructures-cap
branch
from
June 9, 2026 12:24
3607b98 to
52c192c
Compare
kriszyp
marked this pull request as ready for review
June 9, 2026 12:25
cb1kenobi
approved these changes
Jun 9, 2026
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.
Summary
Defaults
maxOwnStructuresto 256 inRecordEncoderand bumpsstructonto^1.0.6(which adds the cap). Bounds the per-encoder typed-structure dictionary that was growing unbounded and OOM-ing under shape-heterogeneous data.Purpose
structon's random-access typed-struct dictionary (
typedStructs+ transition trie) is append-only and pinned on the long-lived primary-store encoder/decoder. The encoder branches per field on the value's numeric width (num8/num32/num64, float32/float64) and string kind, so a wide/sparse schema (~hundreds of distinct key-sets) explodes into tens of thousands of structures — and per-table-per-peer dictionaries, multiplied across worker isolates, OOM-crash-looped a production cluster during replication catch-up of a bulk-loaded table.structon@1.0.6adds an opt-inmaxOwnStructurescap (uncapped by default; see HarperFast/structon#4). This wires it on: once the cap is hit, novel shapes fall back to plain msgpack encoding; the read path is untouched so existing/persisted structs stay decodable. 256 is caller-overridable (a table/DBI option can raise it).Where to look
resources/RecordEncoder.ts(options.maxOwnStructures ??= 256beforesuper(options)), plus thestructondep bump. RecordEncoder extends structon'screateStructon(Encoder).Validation
unitTests/resourcessuite passes (687 passing, 0 failing). The cap logic itself is covered by structon's 94-test suite (structon#4), which exercises exactly thiscreateStructon(msgpackr-v2)+maxOwnStructuresusage. Change is a one-line option default, so no dedicated harper unit test added (RecordEncoder isn't standalone-instantiable; the behavior is upstream-tested).v5.0branch + msgpackr1.11.13.🤖 Generated by Claude (Opus 4.7).