Repository navigation
Avoid rescanning in FormPipeReader when form data arrives incrementally - #10219
Merged
Merged
Conversation
…en form data arrives incrementally Avoids rescanning full body data from pipeReader on any new incoming data ---- #### AI description (iteration 1) #### PR Classification Performance optimization bug fix to eliminate redundant rescanning of form data bytes when data arrives incrementally in FormPipeReader. #### PR Summary This PR fixes a performance issue in FormPipeReader where already-scanned bytes were being rescanned on each incremental read, causing O(n²) behavior. The fix introduces a `scannedLength` parameter to track scanning progress and resume from the correct position. - `FormPipeReader.cs`: Added `scannedLength` parameter to `ParseFormValues`, `ParseFormValuesFast`, and `ParseValuesSlow` methods to track and skip already-scanned bytes, ensuring each byte is scanned at most once plus potential delimiter overlap - `FormPipeReaderTests.cs`: Added comprehensive tests verifying that incremental reads (single-byte and multi-segment) scan each byte only once, and that resumed scans correctly parse whole key-value pairs while still enforcing length limits - `FormPipeReader.cs`: Handles edge cases for multi-byte delimiters (UTF-16/UTF-32) by accounting for delimiter overlap at read boundaries to prevent missing delimiters split across reads <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot --> Co-authored-by: Copilot <[email protected]>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The implementation consistently preserves parsing behavior while avoiding redundant delimiter scans, with comprehensive targeted coverage.
0 open findings
What changed in this PR
Optimizes incremental form parsing by tracking already-scanned bytes and resuming delimiter searches.
Changes:
- Adds scan-position tracking to fast and multi-segment parsing paths.
- Adds incremental-read and multi-byte delimiter tests.
- Updates microbenchmarks for the new parser signature.
| File | Description |
|---|---|
FormPipeReader.cs |
Resumes parsing from the previous scan position. |
FormPipeReaderTests.cs |
Tests incremental reads, limits, and delimiter boundaries. |
FormPipeReaderInternalsBenchmark.cs |
Updates benchmark parser calls. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
DeagleGross
approved these changes
Oct 14, 2026
This was referenced Oct 19, 2026
This was referenced Oct 27, 2026
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.
Avoids rescanning full body data from pipeReader on any new incoming data.