Skip to content

perf(tests): hardlink immutable blobs in template copy - #580

Merged
morluto merged 1 commit into
mainfrom
agent/optimize-test-template-copy
Aug 6, 2026
Merged

perf(tests): hardlink immutable blobs in template copy#580
morluto merged 1 commit into
mainfrom
agent/optimize-test-template-copy

Conversation

@morluto

@morluto morluto commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Summary

The complete-portfolio template contains ~7 MB of content-addressed blobs that are immutable and never modified. Copying them with shutil.copytree for every test causes significant I/O overhead across 80+ composition tests (83 test files × 7 MB = ~580 MB of unnecessary copies).

Fix

Replace copytree with a hybrid approach in tests/support/state.py:

  • Hardlink blobs/ (content-addressed, immutable files)
  • Copy everything else (metadata.sqlite3, lock files)

This eliminates ~7 MB of I/O per test while preserving test isolation — hardlinks share inodes but content-addressed blobs are never modified. New blobs created by a test get new hashes and dont collide.

Validation

  • 3 unit tests in tests/unit/support/test_copy_template.py — all pass
  • 17 composition tests with template fixtures — all pass
  • 3 storage durability tests — all pass

…ying

The complete-portfolio template contains ~7 MB of content-addressed blobs
that are immutable and never modified. Copying them for every test with
shutil.copytree causes significant I/O overhead across 80+ composition tests.

Replace copytree with a hybrid approach: hardlink blobs/ (content-addressed,
immutable) and copy everything else (metadata.sqlite3, lock files). This
eliminishes ~7 MB of I/O per test while preserving isolation — hardlinks
share inodes but content-addressed blobs are never modified.

Includes regression tests verifying hardlinks are used for blobs and copies
for mutable metadata.
@cursor

cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 26fc5afd50

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/support/state.py
if entry.is_dir(follow_symlinks=False):
_hardlink_tree(s, d)
elif entry.is_file(follow_symlinks=False):
os.link(s, d)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid sharing blob inodes across concurrent xdist runtimes

When xdist workers copy the shared session template while another worker writes content whose digest is already present, each os.link changes that shared inode's st_ctime_ns. The existing-blob path in src/jacobian/storage/blobs.py:213-234 explicitly compares signatures, including ctime, before and after reading and reports any change as ArtifactIntegrityError; therefore a concurrent fixture setup can make a valid idempotent artifact write fail as apparent corruption. Use copies/reflinks that do not mutate the source inode's metadata, or otherwise avoid sharing these inodes between simultaneously active runtimes.

Useful? React with 👍 / 👎.

@morluto
morluto merged commit 65b0092 into main Aug 6, 2026
9 of 10 checks passed
@morluto
morluto deleted the agent/optimize-test-template-copy branch August 6, 2026 20:24
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.

1 participant