graph: copy store-linked files with copyFile before scripts run [ci full-matrix] by ruy-bot[bot] · Pull Request #1993 · vltpkg/vltpkg · GitHub
Skip to content

graph: copy store-linked files with copyFile before scripts run [ci full-matrix] - #1993

Open
ruy-bot[bot] wants to merge 1 commit into
mainfrom
ruyadorno/unshare-copy
Open

ruy-bot[bot] wants to merge 1 commit into
mainfrom
ruyadorno/unshare-copy

Conversation

@ruy-bot

@ruy-bot ruy-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

unshare() read each shared file into JS, wrote it to a tmp sibling (+ chmod for bins), then renamed over the link. Now copyFile(p, tmp, COPYFILE_EXCL) + rename: kernel copy where possible, mode kept, no buffer round trip. Shared inode still never written. Refs #1934 (item 1).

Changes

  • reify/unshare: copyFile w/ COPYFILE_EXCL + rename; drop readFile/writeFile/chmod. Concurrency stays 16 (4 and a sync loop measured slower).
  • Copies keep the store file's exact mode (umask no longer re-applied to non-exec files) = what the link exposed.

Tests

  • unshare: store mode kept (fails before), copies use COPYFILE_EXCL into a sibling tmp, copy/partial-copy failures leave links + retry works.

  • Store-untouched build tests unchanged, pass.

  • Perf, large (5,647 files), cache+lockfile, --allow-scripts=:scripts, 20 runs/arm, 16 vCPU Linux (ext4) busy box; median ms, user/sys = mean ms:

    16 CPUs r1 16 CPUs r2 2 CPUs r1 2 CPUs r2 user / sys (16 CPUs r2)
    main 1673 1698 1891 1855 1339 / 1312
    this PR 1685 1636 1831 1811 1264 / 1307
    copy at placement (as before graph: hardlink install-script packages, copy them only before their scripts run #1918) 1560 1541 1620 1619 1116 / 772

    Default install (no scripts): main 1352 / 1348 vs PR 1339 / 1345, unchanged.

  • Wall gain small, often within noise (≈+10…−60 ms); user CPU ≈−40…−110 ms; sys unchanged: per-file rename over the link dominates.

Follow-ups

  • Refs, not Fixes: acceptance cache unzip #1 (within noise of pre-graph: hardlink install-script packages, copy them only before their scripts run #1918) unmet; issue stays open for item 2 or a dir-level unshare.
  • Item 2: copy at placement when allow-scripts matches; needs the query result before placement (:scripts reads manifest/buildState, unknown pre-extract on lockfile installs). Upper bound ≈100-200 ms on large.
  • Dir-level unshare (copy into fresh sibling dir, swap, rm old): ≈35-40 % less unshare time in a micro bench; needs symlink/private-file carry-over, crash recovery, Windows dir-rename EPERM/EBUSY handling.
  • Numbers Linux only; macOS/Windows copy paths differ (CI covers correctness, not perf).

Co-authored-by: Ruy Adorno ruy@vlt.sh

unshare() read each shared file into JS, wrote it to a tmp sibling,
chmod'ed exec files, then renamed over the link. copyFile with
COPYFILE_EXCL copies in the kernel where it can and keeps the mode,
so the read/write round trip and chmod go away. Shared inode still
never written: copy targets a new tmp inode.

Refs #1934

## Changes
- reify/unshare: copyFile(COPYFILE_EXCL) + rename, drop readFile/writeFile/chmod
- copies keep the store file's exact mode (umask not re-applied)

## Tests
- unshare: store mode kept, COPYFILE_EXCL into sibling tmp, copy/partial failures leave links + retry

Co-authored-by: Ruy Adorno <ruy@vlt.sh>
@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Oct 9, 2026 11:53pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ff98243b-f2e1-40e0-9054-d85ce092ef9e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

🐰 Bencher Report

Projectvltpkg
Branchruyadorno/unshare-copy
Testbedubuntu-latest
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
vlt install: vue & cache-lockfile📈 view plot
🚷 view threshold
635.10 ms
(-12.43%)Baseline: 725.26 ms
906.58 ms
(70.05%)
vlt install: vue & cache-lockfile-node-modules📈 view plot
🚷 view threshold
352.89 ms
(+2.19%)Baseline: 345.34 ms
431.68 ms
(81.75%)
vlt install: vue & clean📈 view plot
🚷 view threshold
11,626.07 ms
(-12.06%)Baseline: 13,220.57 ms
16,525.71 ms
(70.35%)
vlt install: vue & lockfile📈 view plot
🚷 view threshold
5,643.09 ms
(+10.94%)Baseline: 5,086.56 ms
6,358.19 ms
(88.75%)
🐰 View full continuous benchmarking report in Bencher

This branch was successfully deployed

1 active deployment
Preview — 70c769ae Deployed Oct 9, 2026 by vercel[bot]
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