Skip to content

perf(runtime): bound Read line-index memory to the page - #5461

Open
seekskyworld wants to merge 1 commit into
apache:mainfrom
seekskyworld:perf/bounded-read-page-index
Open

seekskyworld wants to merge 1 commit into
apache:mainfrom
seekskyworld:perf/bounded-read-page-index

Conversation

@seekskyworld

Copy link
Copy Markdown
Contributor

Summary

A bounded Read page currently allocates one newline offset for every source line, even when requesting only 20 lines. Count total lines with scalar state and retain offsets only within the possible response window. Exact range, continuation-digest, Unicode and response-size semantics remain covered by the existing pager tests.

Fixes #5460

Local synthetic filesystem Read measurements, Node 24.18.1 on macOS arm64, 10 fresh processes per case with warm OS cache:

Source First-read median / p95, before → after Median process peak RSS, before → after
1M × 32-byte lines 26.54/30.12 → 22.41/23.21 ms 184.41 → 149.36 MiB
8M × 2-byte lines (stress) 110.21/124.18 → 74.61/77.97 ms 337.55 → 115.73 MiB

Before: cd93f13da; after: 57d38d69c. Reproduction, smaller fixtures and warm-run results are in the issue. This removes the full-file index allocation; full input reads, exact line counting and content hashing still scale with source size.

Verification

  • New constrained-heap regression: reading 20 lines from 16 MB of short-line text succeeds with a 64 MiB V8 heap. The same test against the old pager fails with heap exhaustion. This is a test budget, not a shipping worker limit.
  • Read/worker focused tests: 32 passed. Full Runtime suite: 3,524 passed, 14 skipped.
  • 16,380 deterministic before/after page comparisons matched, including Unicode, empty lines, deep/out-of-range offsets, limits and continuation chains.
  • Full repository build, typecheck, lint, format check, Desktop/UI knip, ASF header audit and git diff --check passed. Runtime is the affected suite; other full workspace suites and Desktop E2E were not rerun for this internal pager change.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: OpenAI Codex inspected the repository, implemented the pager change and tests, measured performance and prepared this contribution. Human review and merge remain with the project maintainers.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Count total lines without retaining the full file index, and keep only positions inside the bounded response window. Preserve exact range and continuation semantics.

Fixes apache#5460

Generated-by: OpenAI Codex
Signed-off-by: seekskyworld <djh1813553759@gmail.com>
@github-actions github-actions Bot added the effort/S Under 100 readable lines label Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/S Under 100 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(runtime): bound Read line-index memory to the requested page

1 participant