Skip to content

perf(tier3): stream staged baseline file hashes - #912

Open
Afloat16 wants to merge 2 commits into
NVIDIA:mainfrom
Afloat16:perf/stream-baseline-task-hashing-20261126
Open

Afloat16 wants to merge 2 commits into
NVIDIA:mainfrom
Afloat16:perf/stream-baseline-task-hashing-20261126

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Tier 3 computes a digest of every staged baseline task before executing an evaluation. Reading each repository file with read_bytes() creates a file-sized memory copy, so a large binary or dataset fixture can exhaust memory during identity collection even though SHA-256 accepts incremental input.

Hash ordinary staged files in 64 KiB blocks. Preserve the existing length-prefixed identity format, arm-neutral task.toml normalization, symlink representation and exact generated environment/repo-context.json exclusion. Detect files that grow or truncate while the streaming read runs and report the existing pre-execution identity failure rather than publishing an inconsistent length prefix.

Verification

The real-file memory regression fails on unchanged upstream. A 16 MiB staged binary produces exactly the same digest before and after the change; Python allocation peak during hashing falls from 16,786,373 to 140,641 bytes. Fixture construction is outside the measurement, and this is a hashing-memory measurement rather than an overall evaluation throughput claim.

  • 15 focused tests passed, including five persisted-digest compatibility cases around the read boundary, arm normalization, authored/generated context paths, and growth/truncation detection.

  • Required gates passed on Ubuntu 24.04 / Python 3.12 after uv sync --all-extras --locked --python 3.12: make lint, make test, and make build, using the checkout’s .venv/bin/python. Full validation run checked exact contribution head 923fa01ec335e5fcfb6299a7d5a040e794f7a24b; pytest reported 45,547 passed, 338 skipped, 19 deselected. Skips and marker exclusions are the repository’s existing defaults; no new skips or filters were added.

  • The digest compatibility fixture now writes explicit LF line endings so its expected persisted identity is the same on Windows and Unix.

  • Whole-repository make lint, changed-file formatting and git diff --check passed.

  • make build produced the wheel and source distribution.

  • I am familiar with the Contributing Guidelines

  • Added or updated focused tests

  • Updated documentation for user-visible changes

  • Ran make lint

  • Ran full make test successfully on the standard Ubuntu runner

  • Ran make build

  • Did not add credentials, private datasets, or proprietary benchmark content

Release Impact

  • No user-visible release note needed
  • Updated CHANGELOG.md

Signed-off-by: Afloat <ShuffleMonkey@163.com>

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I checked the digest format rather than taking the description on trust: for regular files other than task.toml the only change is that the 8-byte length prefix now comes from fstat on the open descriptor and the content is fed to SHA-256 in 64 KiB chunks, while task.toml normalization, symlinks, directories, the environment/repo-context.json exclusion, header layout and file ordering are untouched. Hashing the same fixture trees with main and this head gives identical digests for empty, 1-byte, 65535/65536/65537-byte, 1 MiB+13 and 48 MiB files, file/dir/broken symlinks, an empty directory, both comparison arms of a task with a -with-skill/-without-skill name plus a generated repo-context.json, and unsorted multi-agent input; a non-UTF-8 task.toml and a chmod 000 file raise the same exceptions on both. The five persisted-digest cases in the new test also pass against main's source, which is the right property for a compatibility test.

Memory does drop as claimed: peak traced allocation while hashing a 48 MiB file goes from about 50 MB to 142 KB, and process RSS from 93 MB to 43 MB. An I/O error after the first chunk propagates as an OSError and no digest is returned (main reads the whole file in one call, so it never had a mid-stream case). A file that grows or shrinks during the read raises ValueError, and the Harbor runner already catches (OSError, UnicodeError, ValueError) around this call and turns it into the pre-execution identity failure, so an inconsistent length prefix cannot reach a persisted baseline. The memory and grow/truncate tests fail on main and pass here, also under Python 3.13, and the 2 MiB threshold has a wide margin over the ~140 KB peak.

One nit inline about write_text newline translation in the new test. CHANGELOG entry is under Unreleased / Changed, the commit is signed off, CI is green, and the branch merges cleanly into main and into the other open perf PRs.

Signed-off-by: Afloat <ShuffleMonkey@163.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants