Avoid rescanning the full buffered line in gets - #172
Open
OskarEichler wants to merge 1 commit into
Open
Conversation
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.
Summary
After an unsuccessful delimiter search, resume at the new data plus the separator overlap needed for matches spanning responses.
Reproduction and evidence
A 16 MiB line followed by CRLF arrives in 8,192-byte responses. Baseline searches the growing prefix again after every response. In three fresh local processes per implementation, median read time was 4.937541s before / 0.012834s after; complete output and file position were checked. A separate initial 32 MiB run measured 24.803344s / 0.019606s. These are local in-memory parser timings, not network throughput.
Verification
Breaking changes and limitations
No intended public behavior change. Full-line memory retention remains necessary for this API; this only eliminates repeated searching of already-scanned prefixes. Existing frozen-string fixes are separate (#157).
No repository tests added or modified under the task's no-new-tests constraint; focused scripts ran outside the repository. An external verification Gemfile supplies test tools/RDoc without changing upstream tooling. Older Ruby/JRuby/Windows and upstream CI have not been verified. No production/SSH connections, unrelated upgrades, release changes or signature-equivalence claim.