Skip to content

perf(read_file): cache line starts for paginated reads - #7152

Open
KYRIE66nb wants to merge 1 commit into
esengine:main-v2from
KYRIE66nb:optimize-readfile-pagination-cache
Open

perf(read_file): cache line starts for paginated reads#7152
KYRIE66nb wants to merge 1 commit into
esengine:main-v2from
KYRIE66nb:optimize-readfile-pagination-cache

Conversation

@KYRIE66nb

Copy link
Copy Markdown

Summary

  • Add a small stat-keyed line-start cache for raw disk read_file reads.
  • Reuse cached byte offsets when continuing through a large file with offset, avoiding repeated rescans of already-indexed pages.
  • Keep the read_file tool schema and model-visible output format unchanged; decoded/overlay paths stay on the existing scanner.

Issues

No linked issue.

Verification

  • go test ./internal/tool/builtin -run TestReadFileReusesLineOffsetCacheForRepeatedPagination -count=1 -v
  • go test ./... -count=1
  • go vet ./...

Cache impact

Cache-impact: low; implementation-only change to read_file execution, with no tool schema, system prompt, memory prefix, output style, or provider request serialization changes.
Cache-guard: go test ./internal/tool/builtin -run TestReadFileReusesLineOffsetCacheForRepeatedPagination -count=1 -v
System-prompt-review: N/A

Cache-aware file reads intentionally page large files to preserve context budget, but continuing through the same file should not rescan every earlier page. This keeps the model-visible schema and output stable while reusing raw-text line starts discovered by prior reads.

Constraint: Preserve read_file schema and output format so provider prompt-cache prefixes remain stable.

Rejected: Build a full-file line index on first read | it would reintroduce large upfront IO and memory work for small windows.

Confidence: high

Scope-risk: narrow

Directive: Keep cached seeks on raw disk text only; transformed encodings should stay on the streaming scanner until arbitrary-byte seek safety is proven.

Cache-impact: low; implementation-only change to read_file execution, with no tool schema or prompt text changes.

Cache-guard: go test ./internal/tool/builtin -run TestReadFileReusesLineOffsetCacheForRepeatedPagination -count=1 -v

Tested: GOPROXY=https://goproxy.cn,direct go test ./... -count=1

Tested: GOPROXY=https://goproxy.cn,direct go vet ./...

Not-tested: desktop module tests; change is limited to the root Go module built-in read_file tool.
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development skills Skill system (internal/skill, internal/tool) labels Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skills Skill system (internal/skill, internal/tool) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant