Priority
P2
Area
Performance improvement
Problem
The benchmark shows decode performance degrades sharply for deeply nested objects compared with other workloads.
Observed locally with bun run bench on Bun 1.3.13:
deeply nested object: encode 0.044 ms/op, decode 21.324 ms/op
large flat object: encode 0.145 ms/op, decode 0.705 ms/op
The deep workload only produces 124 entries, so the slowdown appears tied to path depth and reconstruction overhead rather than entry count alone.
Relevant code paths to inspect:
src/decode.ts: buildParentPathSet() rebuilds parent path strings for every parsed entry.
src/path.ts: unflattenParsed() repeatedly walks deep segment arrays and formats paths during collision handling.
Expected behavior
Deeply nested decode should remain within a reasonable factor of other decode workloads with similar entry counts.
Suggested investigation
Profile parsePath(), buildParentPathSet(), and unflattenParsed() on the existing deep benchmark. Potential optimizations include caching canonical parent path strings during parsing, avoiding repeated path string reconstruction, or carrying parent metadata alongside parsed segments.
Acceptance criteria
- Add a regression benchmark or benchmark comparison notes for deeply nested decode.
- Improve the deep nested decode benchmark by a measurable amount without regressing flat/repeated field workloads.
- Keep existing collision and sparse-array tests passing.
Priority
P2
Area
Performance improvement
Problem
The benchmark shows decode performance degrades sharply for deeply nested objects compared with other workloads.
Observed locally with
bun run benchon Bun 1.3.13:The deep workload only produces 124 entries, so the slowdown appears tied to path depth and reconstruction overhead rather than entry count alone.
Relevant code paths to inspect:
src/decode.ts:buildParentPathSet()rebuilds parent path strings for every parsed entry.src/path.ts:unflattenParsed()repeatedly walks deep segment arrays and formats paths during collision handling.Expected behavior
Deeply nested decode should remain within a reasonable factor of other decode workloads with similar entry counts.
Suggested investigation
Profile
parsePath(),buildParentPathSet(), andunflattenParsed()on the existing deep benchmark. Potential optimizations include caching canonical parent path strings during parsing, avoiding repeated path string reconstruction, or carrying parent metadata alongside parsed segments.Acceptance criteria