← Back to Pull requests

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

Closed
unknown closed this pull request without merging on Oct 13, 2026 00:47 UTC
View on GitHub
unknown unknown commented on Sep 17, 2026 15:49 UTC
Author

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
  • Diff: 288 lines (+216 / -72) across 3 files Reviewer: seekskyworld Review duration: 36538m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 288 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.339
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5461"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.8% (MEDIUM) · Higher = larger blast radius
    39.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.7% · Safe to merge
    15.7%
    Repository