GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — perf(core): ramp chunk size when seeking large files in read by kitlangton · Pull Request #65611 · anomalyco/opencode

Conversation

@kitlangton

@kitlangton kitlangton commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Seeking near the end of a 20 MiB file in read now makes 7 range reads instead of 80.
Applies to any environment (local, paired machine, or remote workspace) with no wire protocol change.

❌ Before

  • ReadToolFileSystem.textPage always read FIRST_CHUNK (256 KiB) per loop step while skipping lines to a high positive offset or a negative/past-end tail.
  • On a 20 MiB remote file, that meant 80 sequential round trips (~6.6 s at 82 ms RTT, ~70 s over an 870 ms relay).

✅ After

  • While skipping lines, the scan chunk grows 4x per step up to MAX_SCAN_CHUNK (4 MiB), clamped to the remaining file size and floored at FIRST_CHUNK (256 KiB) on short reads.
  • Once the requested page is reached, reads return to FIRST_CHUNK so small page reads never over-fetch.
  • Page 1 (offset: 1) still makes a single 256 KiB read.
   if (next !== undefined || byte >= first.info.size) break
-  const more = yield* range(byte, FIRST_CHUNK)
+  const length =
+    entries.length > 0 || (requested > 0 && total >= requested - 1)
+      ? FIRST_CHUNK
+      : Math.max(FIRST_CHUNK, Math.min(chunk.length * 4, MAX_SCAN_CHUNK))
+  const more = yield* range(byte, Math.min(length, first.info.size - byte))

📊 Proof (synthetic 20 MiB file in tool-read-filesystem.test.ts):

Case Reads before Reads after
High positive offset (390_000) 80 7
Negative offset (-100) 80 7
Past-end tail 80 7
Page 1 (offset: 1) 1 (256 KiB) 1 (256 KiB)

👀 Read: packages/core/src/tool/read-filesystem.ts (7 added lines in textPage). The rest is unit tests covering high offsets, tails, NUL rejection, split lines, and short reads.

No feature flag needed (internal read pagination optimization, zero API or wire change) · reviewed once by a second model before pushing

Checks run
  • bun typecheck in packages/core: no errors
  • prettier on both modified files: pass
  • bun test test/tool-read-filesystem.test.ts test/tool-read.test.ts: 98 pass, 0 fail

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kitlangton
perf(core): ramp chunk size when seeking large files in read
d083ca3
@github-actions github-actions Bot added the contributor label Nov 22, 2026
opencodejr[bot]
opencodejr Bot reviewed Nov 22, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The source change looks sound. Chunks only grow while skipping lines toward the requested page, go back to 256 KiB once the page is reached, and are capped at the remaining file size. NUL detection still only covers bytes up to the selected lines. I ran the new read-count tests against the base source and got 80 reads in each scan case, then 7 with this PR. The read suites pass (98/0) and tsc -b is clean.

Public API: unchanged (internal read pagination only, no wire, SDK or config change).

One request, inline: the added tests are much larger than the 7-line fix needs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/test/tool-read-filesystem.test.ts
}
}

describe("ReadToolFileSystem scan ranges", () => {

@opencodejr opencodejr Bot Nov 22, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This adds ~160 lines of tests for a 7-line change. Several cases are hard to follow: hand-built byte layouts with offset arithmetic, and expectations that branch on the loop variable through nested ternaries (offset === 1 ? … : offset === 3 ? …). The read-count table plus the "bounds reads after reaching the page" case cover what this PR changes. Could you cut it down to those two? The CRLF/BOM-at-boundary, early-NUL, tail-reread and short-read loops mostly pin the existing scanner behaviour, and their exact call-length lists will break on any future tuning of the chunk sizes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
kitlangton added 2 commits November 22, 2026 12:43
@kitlangton
test(core): trim read-filesystem scan-range tests
03149e8
@kitlangton
style(core): format read-filesystem tests
9859108
@kitlangton
kitlangton merged commit 4332e24 into dev Nov 22, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@kitlangton
kitlangton deleted the fast-remote-read branch November 22, 2026 20:54
opencodejr[bot]
opencodejr Bot reviewed Nov 22, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The tests are now cut down to the read-count table, the check that reads return to 256 KiB after reaching the page, and one short-read case. Exact call-length lists are gone, which addresses my earlier comment. The source is unchanged since my last review. The read suites pass (88/0) and tsc -b is clean. Public API: unchanged. No new concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BrewTestBot BrewTestBot mentioned this pull request Nov 23, 2026
opencode 2.4.0 Homebrew/homebrew-core#327368
Merged
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
opencode 2.4.0 amrkmn/homebrew-tap#1251
Closed
1 task
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
feat: opencode release v2.4.0 sprisa/opencode-server#95
Merged
@kobzevvv kobzevvv mentioned this pull request Nov 24, 2026
chore(upstream): порт v2.4.1 — 67 в порт, 38 на решение gpt-mem/opencode-mem#223
Open
4 tasks
@scottames-github-bot scottames-github-bot Bot mentioned this pull request Nov 27, 2026
chore(deps): update ⬆️ mise-packages scottames/dots#1181
Merged
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@kitlangton
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.