Skip to content

decoder: Simplify capacity and depth handling - #81

Open
JakubOnderka wants to merge 1 commit into
masterfrom
capacity-handling
Open

JakubOnderka wants to merge 1 commit into
masterfrom
capacity-handling

Conversation

@JakubOnderka

@JakubOnderka JakubOnderka commented Aug 31, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Performance
    • Updated JSON parsing memory allocation to use existing capacity and requested nesting depth.
    • Improved consistency in allocation behavior across DOM and ondemand parsing modes.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c07e545-532b-4d90-9cf7-4ef539e4cbe5

📥 Commits

Reviewing files that changed from the base of the PR and between 3087234 and 3b723f6.

📒 Files selected for processing (1)
  • src/simdjson_decoder.cpp

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change removes adaptive depth allocation logic. DOM and ondemand parsers now allocate with their existing capacity and the requested depth.

Changes

Parser allocation

Layer / File(s) Summary
Use explicit parser allocation parameters
src/simdjson_decoder.cpp
Removes SIMDJSON_DEPTH_CHECK_THRESHOLD and adaptive depth calculations. DOM and ondemand parser allocation now uses existing capacity and requested depth.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 3b723

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: copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: simplifying decoder capacity and depth handling after removing adaptive allocation logic.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch capacity-handling

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 ondemand allocate() 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 return false for valid JSON due to MEMALLOC. 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.

Comment thread src/simdjson_decoder.cpp
SIMDJSON_PHP_TRY(parser->parser.allocate(len, depth));
}

SIMDJSON_PHP_TRY(parser->parser.allocate(parser->parser.capacity(), depth));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants