Skip to content

decoder: Faster decoding temp/memory streams - #76

Merged
JakubOnderka merged 3 commits into
masterfrom
updates-copilot
Aug 10, 2026
Merged

decoder: Faster decoding temp/memory streams#76
JakubOnderka merged 3 commits into
masterfrom
updates-copilot

Conversation

@JakubOnderka

@JakubOnderka JakubOnderka commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Improved JSON decoding from memory-backed and temporary streams, reducing unnecessary data copying.
    • Added support for decoding filtered stream content, including transformations such as converting uppercase JSON booleans to lowercase.
  • Bug Fixes

    • Temporary and memory stream request bodies now decode correctly when stream filters modify their contents.
  • Tests

    • Added coverage for filtered memory and temporary streams.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@JakubOnderka, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 23 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bbb61e3e-e58c-4b2f-8273-e9a4d05e0e51

📥 Commits

Reviewing files that changed from the base of the PR and between ba536cc and e29a3c1.

📒 Files selected for processing (4)
  • php_simdjson.cpp
  • src/simdjson_decoder.cpp
  • tests/decode_stream_memory.phpt
  • tests/decode_stream_temp.phpt
📝 Walkthrough

Walkthrough

Changes

Stream decoding

Layer / File(s) Summary
Buffer extraction and reallocation contract
src/simdjson_decoder_defs.h, src/simdjson_decoder.cpp, php_simdjson.cpp
The reallocation check is externally declared. A helper extracts memory buffers from eligible temporary streams.
Direct stream decoding integration
php_simdjson.cpp
Memory and temporary streams use direct parsing when possible. The existing fallback remains available. Request-body decoding uses the shared helper.
Filtered stream coverage
tests/decode_stream_memory.phpt, tests/decode_stream_temp.phpt
Tests verify filtered memory and temporary streams decode uppercase boolean input successfully.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant simdjson_decode_from_stream
  participant MemoryBufferHelper
  participant simdjsonParser
  Caller->>simdjson_decode_from_stream: decode stream
  simdjson_decode_from_stream->>MemoryBufferHelper: inspect stream buffer
  MemoryBufferHelper-->>simdjson_decode_from_stream: return buffer or NULL
  simdjson_decode_from_stream->>simdjsonParser: parse buffer directly
  simdjsonParser-->>Caller: return decoded value or JSON error
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: faster decoding for temporary and memory-backed streams.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch updates-copilot

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.

Pull request overview

Adds zero-copy decoding for unfiltered memory-backed streams on PHP 8.2+.

Changes:

  • Directly parses eligible memory and temporary stream buffers.
  • Falls back for filtered or file-backed streams.
  • Adds filtered-stream regression tests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
php_simdjson.cpp Implements stream fast path and buffer helper.
src/simdjson_decoder.cpp Exposes padding-check helper.
src/simdjson_decoder_defs.h Declares the helper.
tests/decode_stream_memory.phpt Tests filtered memory streams.
tests/decode_stream_temp.phpt Tests filtered temporary streams.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread php_simdjson.cpp
Comment on lines +312 to +316
if (SIMDJSON_SHOULD_REUSE_PARSER(len)) {
error = php_simdjson_parse_buffer(simdjson_get_reused_parser(), json, len, return_value, associative, depth);
} else {
simdjson_php_parser *simdjson_php_parser = php_simdjson_create_parser();
error = php_simdjson_parse_buffer(simdjson_php_parser, json, len, return_value, associative, depth);
@JakubOnderka
JakubOnderka merged commit d62c906 into master Aug 10, 2026
57 checks passed
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