Object perf#20
Open
AvivDavid23 wants to merge 10 commits into
Open
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1fface9. Configure here.
…, propagate ijson! insert errors - From<HashMap|BTreeMap|Vec|&[..]> for IValue now panics on allocation failure instead of silently yielding IValue::NULL. Split the shared conversion macro: floats keep null-degradation (non-finite has no JSON representation); containers use a panicking variant, restoring the panic-on-OOM contract they had before the fallible API. TryFrom on the concrete container type remains the recoverable path. - ijson! object arms now .unwrap() insert() instead of `let _ =`, matching the array arms — allocation failure panics rather than building a partial object.
…iner OOM, propagate ijson! insert errors" This reverts commit 899c172.
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.

Object memory reduction (~20–40% per object container)
IObjectheader 16B → 8B:{len:usize, cap:usize}→ singleu64(32b len / 32b cap). Flat −8B per object.usize→u32: table slots hold item indices (≤cap < 2^32), so 4B suffices. Halves table:10·cap→5·capbytes.cap ≤ 8store no hash table; lookups linear-scan the items array. Drops the table entirely for the common small object.API — fallible allocation
IObjectmutators (with_capacity,insert,reserve,entry, …) now returnResult<_, IJsonError>, mirroringIArray. Allocation failure and the 32-bit limit are recoverable instead of panicking.Extend/FromIterator/From<HashMap|BTreeMap>→TryExtend/TryFromIterator/TryFrom.TryExtend/TryFromIterator/TryCollecttraits into newsrc/convert.rs;pub usere-exports keep existing paths (ijson::array::TryExtend) working..unwrap()s (Clone, Drop/dealloc, layout, defrag,obj[k]=v) - they preserve the prior panic-on-OOM contract.Compatibility
IObjectis now capped at 2^32−1 (~4.29B) entries (wasusize) — the tradeoff for the packed 8B header + halved table. (IArrayis unaffected; it keeps its pre-existing 2^32−1 cap from its own packed header.)Note
High Risk
Rewrites core
IObjectstorage, lookup, and resize behavior plus a breaking public API; incorrect hash/small-object logic would corrupt maps or lose keys.Overview
IObjectuses less memory per container by packing len/cap into an 8-byte header (was 16 bytes), storing hash-table slots asu32instead ofusize, and omitting the hash table when capacity ≤ 8 (linear scan only). Larger objects keep Robin-Hood probing but on the smaller table.Breaking API: mutating
IObjectAPIs (with_capacity,insert,reserve,entry, …) now returnResult<_, IJsonError>likeIArray, and infallibleExtend/FromIterator/From<HashMap|BTreeMap>are replaced withTryExtend/TryFromIterator/TryFrom. Shared fallible iterator traits live in newsrc/convert.rsand are re-exported from the crate root (and still fromarrayfor compatibility). JSON/CBOR deserialize, serde serialize, andijson!macros propagate allocation errors; internal paths that previously panicked on OOM still use.unwrap()where documented.fuzz_object_opsis added to CI to fuzz insert/remove/get against aHashMaporacle, stressing small↔large table transitions and hash collisions.Compatibility: max entries per object is now 2³²−1 (packed header tradeoff).
Reviewed by Cursor Bugbot for commit 0469d42. Bugbot is set up for automated code reviews on this repo. Configure here.