Skip to content

perf(entropy): separate physical reads from report resolution - #6950

Merged
gensokyo-dev merged 6 commits into
mainfrom
perf/6947-byte-entropy-reads-20261024
Oct 24, 2026
Merged

gensokyo-dev merged 6 commits into
mainfrom
perf/6947-byte-entropy-reads-20261024

Conversation

@gensokyo-dev

@gensokyo-dev gensokyo-dev commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #6947. A 256-byte report block previously forced 256-byte physical reads across an entire file, even outside a small selected window. On real LLVM 16 this required 481,955 reads. The shared CLI/MCP service now fills a bounded 64 KiB buffer and reports the same caller-selected blocks (1,885 reads).

Three alternating production MCP tasks per lane/case show fine-resolution LLVM whole-task medians 29.842 → 8.584 s and 25.286 → 6.358 CPU s. Kernel family peak increases 629.5 → 672.4 MiB; no memory or token saving is claimed. Large-block and small-file controls do not establish stable whole-task acceleration (small-file elapsed median is worse, with overlapping ranges). Reproducible measurements and limits.

Contract and scope

  • Owner: ByteEntropyService, at physical file reading. Existing static-inspection authority; maintainer execution/mutation scope decision is not applicable.
  • CLI/MCP catalog, inputs, capacity limits and outputs stay identical. All selected blocks, complete file hash/entropy, uncertainty and source Evidence survive; no cache or provider dependency added.
  • Existing file admission, identity validation, short-read completion, cancellation, finalization and cleanup retry remain owned by the same service. New regressions cover unaligned windows across buffers, short reads and tails at 256/4096/65536-byte report sizes.
  • Generated metadata/package/install behavior is unchanged. Real verification uses Linux x64 byte reads only; other filesystems/OSes are unverified.

Validation

  • 18 fresh production stdio tasks plus 6 real CLI calls: independent Python histograms/hash/block/run oracle, equal complete report hashes/parent IDs/catalog, and complete source Evidence exports passed.
  • 36 focused source/MCP-boundary tests passed; six serial static tasks and architecture guards passed. After integrating current main 21a20306b, all 36 tests, six static tasks and architecture guards passed again; 3 real MCP/source-export tasks and 3 CLI calls matched every oracle fact and frozen parent/report identity. Integrated test/preparation peak 2.23 GiB.
  • One-CPU quota, 3 GiB early stop/4 GiB hard, no swap; payload exit/cleanup and resource events verified, no OOM. Final whole-scope counters unavailable. Token values are serialized cl100k_base estimates, not model billing.

CI and review

CI 40063693805 failed on four observed baseline test identities, all reproduced on exact CI main 21a20306b; three available assertion first lines match, while one canceled case has no final CI assertion message. Two built shards passed, one failed and five were canceled, leaving incomplete broader coverage. Source reported 17,303 passed / 2 failed / 13 skipped. Static/build/Windows and the three real Linux binary/crash lanes passed. Exact-head Codex review completed with no findings. Full attribution, controls and limits.

The full local baseline control additionally had two 30-second negotiation timeouts; these are retained and are not attributed to CI. A targeted rerun reproduced the two observed built-case failures. Bypass is authorized by the requester; full-suite success is not claimed. Fresh actual-merge qualification follows integration.

Author readiness

Human owner: @gensokyo-dev

The requester explicitly authorized ready PRs, merging, baseline-CI bypass with evidence, and waiver of repeat human declarations. The following human attestations remain unchecked; this agent does not claim human review occurred.

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T04:48:31.248319Z 1d55e27 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@gensokyo-dev

Copy link
Copy Markdown
Collaborator Author

Source-test failure attribution for exact head 1d55e277ad052985d519a8f8fdfea4753089263d:

CI run 40063693805 tested merge fc1be35eb304f23418f257486030a008e1973414 against actual main 21a20306b4887ff8e6b614b6ae34a387cfbdf1d8. Source tests report 17,303 passed / 2 failed / 13 skipped. The entropy service's 23 tests passed.

Both failures are in src/native/AppleDispatchMetadata.failure.test.ts:

  • keeps path source-read refusals distinct from provider execution failures
  • preserves the filesystem outcome ENOENT for a selected metadata target

A clean detached checkout of that exact main reproduced 2 failed / 3 passed in the whole file, with identical test names and first assertion messages: expected AnalysisInputError, received AnalysisArtifactChangedError. This PR changes neither that file nor its native/artifact implementation.

Executed on the exact-main checkout:

node scripts/run-exact-tests.mjs run src/native/AppleDispatchMetadata.failure.test.ts \
  --maxWorkers=1 --reporter=json --outputFile=/tmp/rea-perf-byte-entropy-20261024/ci-exact-main-source.json

The one-CPU/3 GiB-early/4 GiB-hard guarded control exited 1 for those expected failures, with verified cleanup and no guard stop/OOM. Raw source log, JSON control, resource receipt and name/message comparison are retained in /tmp/rea-perf-byte-entropy-20261024/ci-source-attribution.json and adjacent files. This is baseline attribution, not real Apple-provider qualification.

The other CI shards are still running; their outcome is not yet claimed. No unrelated native-dispatch repair is included in this entropy optimization. The requester authorized bypass of demonstrated baseline failures and waived repeated human declarations; the existing human-review attestations remain unchecked.

@gensokyo-dev

Copy link
Copy Markdown
Collaborator Author

Final qualification for exact head 1d55e277ad052985d519a8f8fdfea4753089263d (CI 40063693805):

  • Static/build/Windows controls and real binary-layout plus both Ubuntu/Debian recorded-crash lanes passed. Codex completed this exact head with no findings; inline review comments are empty.
  • Source: 17,303 passed / 2 failed / 13 skipped; both Apple dispatch error-classification failures reproduce on exact CI main 21a20306b, with matching test names and first assertion messages (source attribution). Entropy service 23 cases passed.
  • Built shard 4: 1,870 passed / 11 skipped; shard 6: 1,641 passed / 49 skipped. Shard 1 failed one corrupted-catalog control; five other shards were canceled. The six binary-diagnostics MCP cases passed in canceled shard 7. Broader canceled coverage is incomplete, not green.

I read all eight archived shard logs. The only additional failing test leaves are:

  1. deferredRuntime.test.ts: rejects a corrupted build-owned catalog before starting the connection. Its copied package omits scripts/lib/cli-process-environment.mjs, so Node reports ERR_MODULE_NOT_FOUND before the intended catalog refusal. Exact-main control reproduces the same first assertion message.
  2. Canceled shard 8, applicationWorkflowCli.test.ts: keeps exact static keys and omits computed names through CLI and MCP. Exact-main control reproduces this failing identity; the final CI assertion message is unavailable after cancellation, so matching unseen assertion text is not claimed.

The full two-file main control ran 66 tests: 62 passed and 4 failed, including those two cases plus two additional 30-second full-discovery negotiation timeouts in the one-CPU local run. Those extra timeouts are retained and are not attributed to CI. A targeted exact-main rerun reproduced both observed failing cases again (2 failed, 64 not selected). Source and both built controls exited 1 for their recorded failures; owned cleanup and memory/PID-limit observations verified, no guard stop/OOM. The full-control family peaked at 2.07 GiB.

All four observed CI failing identities therefore reproduce on the exact CI main; three available assertion first lines match, and one canceled message remains unknown. This PR changes none of these native/JavaScript/runtime-test implementations. Raw JSON/guard logs and archived CI logs are retained in /tmp/rea-perf-byte-entropy-20261024/ci-attribution.json and adjacent files.

Local qualification of this focused entropy change passed 36 cases, 18 paired real MCP tasks, 6 real CLI calls, plus 3 MCP/source-export and 3 CLI integration checks, with independent file histograms/hash/blocks/runs and identical source Evidence. The requester authorized bypass of demonstrated unrelated baseline failures and repeat human declarations; human-review attestations remain unchecked. Merge will be followed by fresh-checkout qualification of the actual merge commit.

@gensokyo-dev
gensokyo-dev merged commit b5c42df into main Oct 24, 2026
31 of 42 checks passed
@gensokyo-dev
gensokyo-dev deleted the perf/6947-byte-entropy-reads-20261024 branch October 24, 2026 05:16
@gensokyo-dev

Copy link
Copy Markdown
Collaborator Author

Postmerge qualification of b5c42dfc2a8eddeffb8d37c669178fa04169f050 completed in a fresh detached checkout:

  • All 36 affected source/MCP-boundary cases passed. Guarded preparation/test family peak was 2.35 GiB.
  • Three real production stdio/source-export tasks and three CLI calls (LLVM fine window, LLVM large blocks, GNU ls) passed every independent histogram/hash/block/run fact. Parent IDs and complete report digests match the frozen cohort; each complete CLI record is identical to its MCP-exported parent Evidence.
  • All five guarded process families exited 0 with verified cleanup, no guard stop/OOM or memory/PID-limit events. Final whole-scope counters remain unavailable. Matching locked dependencies were reused without installing unrelated host software; source checkout is clean.

The fixed 18-task performance comparison remains tied to its published pins: fine-resolution LLVM whole-task median 29.842→8.584 seconds and CPU 25.286→6.358 seconds, with ~43 MiB higher kernel peak and unchanged token estimates. Other controls do not establish stable whole-task acceleration; no actual model-usage saving is claimed.

CI attribution and its canceled-coverage limits remain unchanged. The four observed failure identities reproduced on the exact original main; the requester authorized the baseline/readiness bypass. Codex completed the exact-head review without findings. These checks qualify this static Linux byte-inspection change and do not claim broad canceled-suite or real Apple-provider success. Receipts: /tmp/rea-perf-byte-entropy-20261024/postmerge-summary.json and adjacent raw logs.

@morluto morluto added the performance Performance regressions, scaling limits, and bounded-resource work label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance regressions, scaling limits, and bounded-resource work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: decouple byte entropy reads from output block size

2 participants