decoder: Simplify capacity and depth handling - #81
JakubOnderka wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change removes adaptive depth allocation logic. DOM and ondemand parsers now allocate with their existing capacity and the requested depth. ChangesParser allocation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change simplifies parser capacity and depth allocation in the decoder without introducing an actionable merge-blocking risk; it is merge-ready after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🟡 Changes recommended
Unbounded accepted depths can trigger multi-gigabyte allocations and break existing depth-memory behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Simplifies parser allocation by reusing existing capacity while applying requested nesting depth.
Changes:
- Removes depth-reduction heuristics.
- Aligns DOM and ondemand allocation behavior.
File summaries
| File | Description |
|---|---|
src/simdjson_decoder.cpp |
Updates capacity and depth allocation logic. |
Review details
Suppressed comments (1)
src/simdjson_decoder.cpp:677
- The validation path has the same unbounded-depth regression:
simdjson_validate_depth()currently accepts depths up to roughly 2^31, and ondemandallocate()forwards that value to the DOM implementation's per-level stacks. Consequently, validating even a tiny non-scalar document with a large accepted depth can attempt multi-gigabyte allocations and returnfalsefor valid JSON due toMEMALLOC. Apply the same safe effective-depth bound here as in the DOM path before allocating.
SIMDJSON_PHP_TRY(parser->ondemand_parser.allocate(parser->ondemand_parser.capacity(), depth));
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| SIMDJSON_PHP_TRY(parser->parser.allocate(len, depth)); | ||
| } | ||
|
|
||
| SIMDJSON_PHP_TRY(parser->parser.allocate(parser->parser.capacity(), depth)); |
Summary by CodeRabbit