Skip to content

Avoid rescanning the full buffered line in gets - #172

Open
OskarEichler wants to merge 1 commit into
net-ssh:masterfrom
OskarEichler:codex/gets-incremental-search
Open

Avoid rescanning the full buffered line in gets#172
OskarEichler wants to merge 1 commit into
net-ssh:masterfrom
OskarEichler:codex/gets-incremental-search

Conversation

@OskarEichler

Copy link
Copy Markdown

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

  • Baseline and this isolated patch: 433 existing tests / 1,201 assertions, no failures/errors/skips, Ruby 4.0.6 via rbenv, net-ssh 7.3.3, Minitest 5.27.0 and Mocha 2.1.0.
  • 12,000 external assertions compare output and positions with StringIO over 1,200 deterministic fragmented streams, including repeated/multi-character delimiters, response-boundary overlap, nil separator, limits and EOF.
  • Combined candidate also passes the prior 10,384 model assertions, 12,200 additional mixed line/glob assertions, 27 bounded local OpenSSH pipe checks and the existing suite with frozen literals enabled and disabled. Combined checks include the separately proposed Write at the logical position after buffered reads #163Preserve numeric create and truncate flags in v5 open requests #170 and attributed portions of Handle frozen strings #157/ensure ruby 4 compatibility and address some security concerns #162; these are not additional changes in this PR.
  • All 37 package paths and dependency metadata preserved. All 26 runtime files compile on Ruby 4.0.6 and parse as Ruby 2.5. Comparative Lint retains the same 33 baseline findings; no full-green claim.

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.

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.

1 participant