Skip to content

fix(fs): make concurrent Windows junction creation atomic - #13009

Merged
zkochan merged 13 commits into
pnpm:mainfrom
Stanzilla:fix/windows-global-store-symlinks
Jul 15, 2026
Merged

zkochan merged 13 commits into
pnpm:mainfrom
Stanzilla:fix/windows-global-store-symlinks

Conversation

@Stanzilla

@Stanzilla Stanzilla commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • create Windows junctions under unique sibling paths before committing them to their final locations
  • serialize only the final existence-check and rename step so concurrent package edges reuse the completed junction
  • keep rename, inspection, and staging-cleanup failures visible without masking a concurrently completed destination
  • cover concurrent same-link junction creation on Windows without mutating the process-wide writer cache

Root cause

When true directory symlinks are unavailable, the Rust filesystem layer falls back to the junction crate. That crate creates a normal directory at the final link path and then converts it into a reparse point. Concurrent global-virtual-store edges could observe or replace that intermediate directory, causing ERROR_DIRECTORY (os error 267) during dependency installation.

The new path creates each junction at a unique sibling path, then commits it under a short process-wide lock. Other workers see only a complete junction and flow through the existing AlreadyExists reuse path.

Validation

  • cargo test -p pacquet-fs
  • cargo clippy -p pacquet-fs --all-targets -- --deny warnings
  • PATH="$HOME/.cargo/bin:$PATH" just ready
  • PATH="$HOME/.cargo/bin:$PATH" just dylint

Written by an agent (GitHub Copilot CLI, gpt-5.6-sol).

Summary by CodeRabbit

  • Bug Fixes

    • Resolved concurrent package linking failures on Windows when directory symlinks fall back to junctions.
    • Improved junction creation reliability and recovery under contention and missing parent directories.
  • Tests

    • Added Windows concurrency regression coverage to stress simultaneous junction creation and verify correct reuse behavior.
    • Added Windows regression coverage for junction creation when intermediate parent directories are missing.
  • Chores

    • Updated the Windows-focused changeset with a patch bump for the affected package.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Windows directory symlink creation now injects the creator through retries, while Windows junctions use staged, serialized commits with destination inspection and cleanup. Regression tests cover concurrent callers and missing link parents, and CI runs the missing-parent scenario.

Changes

Windows junction atomicity

Layer / File(s) Summary
Atomic junction creation and fallback wiring
pnpm/crates/fs/src/symlink_dir.rs
Windows junction creation uses unique staging paths, serialized commits, destination inspection, cleanup, and conflict handling. Dispatcher and permission fallback paths use the staged implementation.
Symlink retry wiring and regression coverage
pnpm/crates/fs/src/symlink_dir.rs, pnpm/crates/fs/src/symlink_dir/tests.rs, .github/workflows/pacquet-ci.yml, .changeset/windows-atomic-junctions.md
Retry paths preserve the injected symlink creator; Windows tests cover concurrent creation and missing link parents; CI runs the targeted regression test; the changeset declares a patch release.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • pnpm/pnpm#11684: Modifies Windows symlink_dir junction selection and fallback paths with related tests.

Suggested labels: product: pacquet

Suggested reviewers: zkochan, copilot

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@Stanzilla
Stanzilla marked this pull request as ready for review July 14, 2026 22:35
@Stanzilla
Stanzilla requested a review from zkochan as a code owner July 14, 2026 22:35
Copilot AI review requested due to automatic review settings July 14, 2026 22:35
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a Windows-specific regression test intended to reproduce a race when multiple threads concurrently create the same junction-backed directory link (observed as ERROR_DIRECTORY / os error 267 in native installs). It also adds a test-only hook to force the Windows implementation into junction mode to make the race reproducible regardless of symlink privileges.

Changes:

  • Add a Windows concurrency regression test that spawns multiple threads racing to create the same junction link and asserts only one writer “creates” while the rest reuse.
  • Add a #[cfg(test)] helper to force the Windows symlink writer to use the junction branch.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pnpm/crates/fs/src/symlink_dir/tests.rs Adds a Windows regression test for concurrent junction creation behavior.
pnpm/crates/fs/src/symlink_dir.rs Adds a test-only helper to force junction mode in the Windows writer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pnpm/crates/fs/src/symlink_dir/tests.rs Resolved
Comment thread pnpm/crates/fs/src/symlink_dir.rs Resolved
@greptile-apps

greptile-apps Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The change is safe to merge. It introduces new Windows-only production code and accompanying tests; no cross-platform logic is affected.

The staging-plus-lock approach is sound: each worker gets a unique path derived from PID and a monotonic counter, so there is no reuse across process runs or between concurrent callers. The commit lock correctly serializes only the existence-check + rename step, keeping the expensive junction creation parallel. Post-rename and post-cleanup error paths all return AlreadyExists-kinded errors so force_symlink_inner routes them to the reuse branch rather than failing the install. The ConcurrentCleanupWarning mechanism correctly propagates diagnostic text without blocking the install. All three concerns from the previous review rounds are fully resolved in this commit, and the new concurrency regression test exercises exactly the original failure scenario.

No files require special attention.

Reviews (12): Last reviewed commit: "chore(ci): remove temporary Windows boot..." | Re-trigger Greptile

Comment thread pnpm/crates/fs/src/symlink_dir/tests.rs Resolved
Comment thread pnpm/crates/fs/src/symlink_dir.rs Resolved
@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 939bb7d1281b

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.995 ± 0.529 3.670 5.400 1.87 ± 0.28
pacquet@main 3.736 ± 0.167 3.609 4.153 1.75 ± 0.15
pnpr@HEAD 2.132 ± 0.154 1.978 2.427 1.00
pnpr@main 2.199 ± 0.150 1.995 2.370 1.03 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.9947898384000005,
      "stddev": 0.5289049494919972,
      "median": 3.7733728212,
      "user": 3.5879353800000002,
      "system": 3.4579926800000003,
      "min": 3.6695105302,
      "max": 5.4004400662,
      "times": [
        5.4004400662,
        3.7009209682,
        3.7401518782000003,
        4.203581124199999,
        4.1512701802,
        3.6823796052,
        3.7516796322,
        3.8528983892000004,
        3.6695105302,
        3.7950660102000002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.736362246400001,
      "stddev": 0.16652819936002072,
      "median": 3.6750886867,
      "user": 3.54086948,
      "system": 3.4374007799999995,
      "min": 3.6092284522000004,
      "max": 4.1529259642,
      "times": [
        4.1529259642,
        3.6092284522000004,
        3.6670332012,
        3.6322062212,
        3.6670347662,
        3.6976192442,
        3.6831426072,
        3.8996201962000003,
        3.6500477642000004,
        3.7047640472000003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.1317741164000004,
      "stddev": 0.15381221135716217,
      "median": 2.0566629612000003,
      "user": 2.70882848,
      "system": 3.0566375799999994,
      "min": 1.9784981732,
      "max": 2.4267371982,
      "times": [
        2.0275575592000004,
        2.0245109202,
        2.1913917872,
        2.0228579982,
        2.0121890492000003,
        2.3361817822,
        2.4267371982,
        1.9784981732,
        2.0857683632,
        2.2120483332000003
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.1986858172000003,
      "stddev": 0.15048303125328175,
      "median": 2.2208318062000005,
      "user": 2.64221488,
      "system": 3.0538555799999996,
      "min": 1.9949159082,
      "max": 2.3702773912,
      "times": [
        2.3283055112000004,
        2.1049654842,
        2.1157227622000003,
        2.0657147712,
        1.9949159082,
        2.3702773912,
        2.3259408502000003,
        2.3333100202000003,
        2.0203264792,
        2.3273789942
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 654.1 ± 6.8 641.9 664.0 1.00
pacquet@main 667.5 ± 29.2 645.0 747.0 1.02 ± 0.05
pnpr@HEAD 741.7 ± 72.4 691.8 927.1 1.13 ± 0.11
pnpr@main 727.3 ± 56.6 682.2 872.9 1.11 ± 0.09
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6540759325200001,
      "stddev": 0.006827726111968664,
      "median": 0.65443563492,
      "user": 0.38275403999999996,
      "system": 1.3406391,
      "min": 0.64193611492,
      "max": 0.66398090192,
      "times": [
        0.64193611492,
        0.66398090192,
        0.6579781759200001,
        0.6599667409200001,
        0.65386839992,
        0.65110824392,
        0.6481179769200001,
        0.6481257489200001,
        0.66067415192,
        0.65500286992
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6674617827200001,
      "stddev": 0.029236323431586622,
      "median": 0.6596030204200001,
      "user": 0.38399803999999993,
      "system": 1.3486395,
      "min": 0.64501182292,
      "max": 0.7470291509200001,
      "times": [
        0.6770824819200001,
        0.6607776469200001,
        0.65804460492,
        0.64501182292,
        0.66114267392,
        0.66106559892,
        0.64790538892,
        0.6581300639200001,
        0.6584283939200001,
        0.7470291509200001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.74171450642,
      "stddev": 0.07237750334520944,
      "median": 0.71245131892,
      "user": 0.39830204,
      "system": 1.3707227999999998,
      "min": 0.6917663929200001,
      "max": 0.9271332699200001,
      "times": [
        0.79761837392,
        0.7453643159200001,
        0.70078034592,
        0.69920228792,
        0.6917663929200001,
        0.6996284839200001,
        0.70765588292,
        0.9271332699200001,
        0.73074895592,
        0.71724675492
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7272561586200001,
      "stddev": 0.056581303563296555,
      "median": 0.7093720544200001,
      "user": 0.39334463999999997,
      "system": 1.3725484000000001,
      "min": 0.68217002392,
      "max": 0.8729118089200001,
      "times": [
        0.6988428469200001,
        0.6976853339200001,
        0.68357908692,
        0.7105470249200001,
        0.68217002392,
        0.71552941392,
        0.8729118089200001,
        0.7488163899200001,
        0.75428257292,
        0.70819708392
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.294 ± 0.048 4.218 4.363 1.97 ± 0.06
pacquet@main 4.239 ± 0.035 4.201 4.302 1.94 ± 0.06
pnpr@HEAD 2.181 ± 0.065 2.099 2.286 1.00
pnpr@main 2.241 ± 0.107 2.110 2.373 1.03 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.294160315299999,
      "stddev": 0.047913931195528024,
      "median": 4.294548063400001,
      "user": 3.7890636799999995,
      "system": 3.44730364,
      "min": 4.2181518304,
      "max": 4.3630378384,
      "times": [
        4.2181518304,
        4.2829372094,
        4.2942849414,
        4.3396038744,
        4.3630378384,
        4.3488931344,
        4.2948111854,
        4.2487218364,
        4.2424291713999995,
        4.3087321314
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.2385958389,
      "stddev": 0.03518117404084179,
      "median": 4.235211790399999,
      "user": 3.7298760799999995,
      "system": 3.409938139999999,
      "min": 4.2006690874,
      "max": 4.3019023214,
      "times": [
        4.2811316734,
        4.2381764664,
        4.2542183364,
        4.2591669054,
        4.2322471144,
        4.2052844974,
        4.3019023214,
        4.2094731484,
        4.2006690874,
        4.2036888384
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.1809703244999996,
      "stddev": 0.06489972933872258,
      "median": 2.1809462619,
      "user": 2.5406659799999995,
      "system": 2.9448200399999998,
      "min": 2.0993268494,
      "max": 2.2858752663999997,
      "times": [
        2.1012881984,
        2.2379853454,
        2.1074137954,
        2.1732594274,
        2.2251293764,
        2.2324240304,
        2.1886330964,
        2.0993268494,
        2.1583678593999998,
        2.2858752663999997
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.2408652688999995,
      "stddev": 0.10650092094959714,
      "median": 2.2135900254000003,
      "user": 2.4732157799999994,
      "system": 2.97768964,
      "min": 2.1097335254,
      "max": 2.3725554614,
      "times": [
        2.1243458133999997,
        2.3240913764,
        2.2167402764,
        2.1923171394,
        2.2104397744,
        2.3704136094,
        2.3588417254,
        2.3725554614,
        2.1291739873999997,
        2.1097335254
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.343 ± 0.011 1.323 1.358 2.02 ± 0.03
pacquet@main 1.386 ± 0.081 1.337 1.613 2.08 ± 0.12
pnpr@HEAD 0.670 ± 0.035 0.645 0.768 1.01 ± 0.05
pnpr@main 0.665 ± 0.008 0.654 0.679 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.34277832874,
      "stddev": 0.011164392776721611,
      "median": 1.34367342304,
      "user": 1.29223812,
      "system": 1.71078222,
      "min": 1.32272083504,
      "max": 1.35812176304,
      "times": [
        1.3282851310400001,
        1.3544171650399999,
        1.32272083504,
        1.35812176304,
        1.33717425704,
        1.34601339904,
        1.34939813204,
        1.34133344704,
        1.3495998600399999,
        1.34071929804
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.3862776482399999,
      "stddev": 0.0811486971159814,
      "median": 1.35956768704,
      "user": 1.30763762,
      "system": 1.73818612,
      "min": 1.33727972904,
      "max": 1.61251013004,
      "times": [
        1.38880553904,
        1.61251013004,
        1.38393872704,
        1.35347594704,
        1.35704853004,
        1.36208684404,
        1.34322752104,
        1.35371328704,
        1.37069022804,
        1.33727972904
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.67045210614,
      "stddev": 0.034960866769563025,
      "median": 0.6611080140400001,
      "user": 0.33360812,
      "system": 1.2917949199999998,
      "min": 0.6445973700400001,
      "max": 0.76791560404,
      "times": [
        0.66511502004,
        0.6445973700400001,
        0.6621937370400001,
        0.65714534104,
        0.76791560404,
        0.66002229104,
        0.66657187204,
        0.65963042804,
        0.6686167820400001,
        0.65271261604
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.66508983414,
      "stddev": 0.007782942471721463,
      "median": 0.6638636440400001,
      "user": 0.34535541999999997,
      "system": 1.28902762,
      "min": 0.6537289900400001,
      "max": 0.6788719320400001,
      "times": [
        0.66354454304,
        0.6567324090400001,
        0.6537289900400001,
        0.6717969580400001,
        0.66076141604,
        0.66081620204,
        0.6641827450400001,
        0.6788719320400001,
        0.6672119830400001,
        0.67325116304
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.048 ± 0.065 2.986 3.215 4.42 ± 0.26
pacquet@main 3.058 ± 0.061 2.997 3.210 4.43 ± 0.26
pnpr@HEAD 0.690 ± 0.010 0.675 0.711 1.00 ± 0.06
pnpr@main 0.690 ± 0.038 0.662 0.794 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.04809216802,
      "stddev": 0.0651426385757837,
      "median": 3.02052424662,
      "user": 1.7762440800000001,
      "system": 1.9984982599999999,
      "min": 2.98572890912,
      "max": 3.21536974112,
      "times": [
        3.01481387912,
        3.01625974512,
        3.01126529912,
        2.98572890912,
        3.01589294712,
        3.06731761112,
        3.02478874812,
        3.21536974112,
        3.07778510812,
        3.05169969212
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.0578040476200004,
      "stddev": 0.06065621634869265,
      "median": 3.03972804962,
      "user": 1.76047668,
      "system": 2.0082962599999994,
      "min": 2.99736687212,
      "max": 3.21013282812,
      "times": [
        3.02458901912,
        3.07305178712,
        3.08196601312,
        3.02010229212,
        3.05190279612,
        2.99736687212,
        3.02755330312,
        3.21013282812,
        3.01677943612,
        3.07459612912
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6899406301200001,
      "stddev": 0.009895776767199714,
      "median": 0.68909247712,
      "user": 0.3362122799999999,
      "system": 1.3147470600000002,
      "min": 0.6747008761200001,
      "max": 0.71051288412,
      "times": [
        0.69652810012,
        0.6881436001200001,
        0.68851300012,
        0.6792962411200001,
        0.71051288412,
        0.69666601912,
        0.6747008761200001,
        0.68967195412,
        0.68974134412,
        0.68563228212
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6897362335200001,
      "stddev": 0.03756012819177892,
      "median": 0.68191099862,
      "user": 0.35631828,
      "system": 1.29580496,
      "min": 0.66184382312,
      "max": 0.79380747512,
      "times": [
        0.6843346381200001,
        0.6674337851200001,
        0.69012764012,
        0.67720936712,
        0.68472103112,
        0.67406257812,
        0.68426926412,
        0.66184382312,
        0.79380747512,
        0.6795527331200001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 662.1 ± 7.8 652.7 675.5 6.13 ± 0.08
pacquet@main 660.8 ± 6.6 650.8 675.3 6.12 ± 0.07
pnpr@HEAD 108.0 ± 0.8 107.1 110.9 1.00
pnpr@main 108.1 ± 0.8 107.0 111.6 1.00 ± 0.01
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.66214303322,
      "stddev": 0.007812755201649037,
      "median": 0.66200683272,
      "user": 0.6273050999999998,
      "system": 0.15438340000000003,
      "min": 0.6526745632200001,
      "max": 0.6755317352200001,
      "times": [
        0.65720976822,
        0.6526745632200001,
        0.66160291922,
        0.6656142902200001,
        0.6624107462200001,
        0.65704050222,
        0.66258434722,
        0.67373443822,
        0.6530270222200001,
        0.6755317352200001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.66077277922,
      "stddev": 0.006637724911386313,
      "median": 0.65840338722,
      "user": 0.6216875,
      "system": 0.1606304,
      "min": 0.65081090322,
      "max": 0.67528808222,
      "times": [
        0.66705401722,
        0.65821594622,
        0.67528808222,
        0.6581358782200001,
        0.65756775722,
        0.66137286222,
        0.66333733622,
        0.65735418122,
        0.65081090322,
        0.65859082822
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.10802631546000002,
      "stddev": 0.0007503543810435675,
      "median": 0.10793396822000001,
      "user": 0.028086659999999996,
      "system": 0.01976052,
      "min": 0.10713548922,
      "max": 0.11093707622000001,
      "times": [
        0.11093707622000001,
        0.10713548922,
        0.10813712422,
        0.10793396822000001,
        0.10846742122000001,
        0.10733688922000001,
        0.10819038322,
        0.10807167222000001,
        0.10755218222000001,
        0.10837177922,
        0.10750477322,
        0.10783315322,
        0.10765927122,
        0.10864904122,
        0.10771543722,
        0.10774531222000001,
        0.10780446322000001,
        0.10809968522,
        0.10814372722000001,
        0.10804187122,
        0.10757041022000001,
        0.10854794722000001,
        0.10718090222000001,
        0.10868915922000001,
        0.10733874722
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.10806959626000001,
      "stddev": 0.0008489643521607909,
      "median": 0.10789031422,
      "user": 0.028312099999999996,
      "system": 0.020218000000000003,
      "min": 0.10698621922000001,
      "max": 0.11164882022000001,
      "times": [
        0.10788080022,
        0.11164882022000001,
        0.10789031422,
        0.10775870122,
        0.10850941422,
        0.10741386822000001,
        0.10841092022000001,
        0.10808066422000001,
        0.10777276822000001,
        0.10804303322000001,
        0.10772643122,
        0.10829501422000001,
        0.10759881322,
        0.10806492422000001,
        0.10732660422000001,
        0.10867241922000001,
        0.10698621922000001,
        0.10863691222,
        0.10774377422,
        0.10771636222000001,
        0.10824357822000001,
        0.10814642622000001,
        0.10793110422,
        0.10757821522000001,
        0.10766380422
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.594 ± 0.151 6.411 6.936 1.33 ± 0.04
pacquet@main 6.647 ± 0.180 6.431 7.005 1.34 ± 0.04
pnpr@HEAD 4.997 ± 0.068 4.908 5.089 1.01 ± 0.02
pnpr@main 4.969 ± 0.076 4.854 5.062 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.59441245382,
      "stddev": 0.15132872690656607,
      "median": 6.56471542102,
      "user": 3.79233014,
      "system": 3.74787696,
      "min": 6.41122957452,
      "max": 6.93622945752,
      "times": [
        6.51585552952,
        6.60162076652,
        6.56581203652,
        6.56361880552,
        6.41122957452,
        6.48970587752,
        6.69823241852,
        6.93622945752,
        6.69407486152,
        6.46774521052
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.647287134220001,
      "stddev": 0.17984364045162218,
      "median": 6.64116760852,
      "user": 3.6928603399999993,
      "system": 3.73893396,
      "min": 6.43094057252,
      "max": 7.0053131105199995,
      "times": [
        6.68079025452,
        6.5111681705199995,
        6.62689511152,
        6.85877902652,
        7.0053131105199995,
        6.5903640895199995,
        6.68219143252,
        6.43094057252,
        6.65544010552,
        6.43098946852
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 4.99729534202,
      "stddev": 0.06801710270463797,
      "median": 5.01760275702,
      "user": 2.7998854399999997,
      "system": 3.2707039599999996,
      "min": 4.90826784752,
      "max": 5.08948181552,
      "times": [
        4.91030345352,
        5.02903607552,
        4.91975085552,
        4.95837362452,
        5.06632369452,
        5.08948181552,
        5.02254690552,
        5.01265860852,
        5.05621053952,
        4.90826784752
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 4.96939232972,
      "stddev": 0.07579732675591039,
      "median": 4.98444047152,
      "user": 2.75982994,
      "system": 3.2742767599999993,
      "min": 4.85381302652,
      "max": 5.06159746652,
      "times": [
        5.01966411752,
        5.05186336652,
        4.96817358052,
        4.86129174952,
        4.97483157352,
        5.01652430952,
        4.85381302652,
        5.06159746652,
        4.99404936952,
        4.89211473752
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/13009
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,294.16 ms
(+0.46%)Baseline: 4,274.36 ms
5,129.24 ms
(83.72%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,048.09 ms
(+1.13%)Baseline: 3,013.97 ms
3,616.76 ms
(84.28%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,342.78 ms
(+0.29%)Baseline: 1,338.96 ms
1,606.75 ms
(83.57%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
662.14 ms
(+5.09%)Baseline: 630.09 ms
756.11 ms
(87.57%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
3,994.79 ms
(+3.54%)Baseline: 3,858.24 ms
4,629.89 ms
(86.28%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,594.41 ms
(-6.34%)Baseline: 7,040.85 ms
8,449.02 ms
(78.05%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
654.08 ms
(+0.93%)Baseline: 648.07 ms
777.69 ms
(84.11%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/13009
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,180.97 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
689.94 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
670.45 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
108.03 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,131.77 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
4,997.30 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
741.71 ms
🐰 View full continuous benchmarking report in Bencher

Copilot AI review requested due to automatic review settings July 14, 2026 23:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread .github/workflows/pacquet-ci.yml Resolved
Comment thread pnpm/crates/fs/src/symlink_dir/tests.rs Resolved
Comment thread pnpm/crates/fs/src/symlink_dir.rs Resolved
@codecov-commenter

codecov-commenter commented Jul 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.57143% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.53%. Comparing base (b49c224) to head (62daba3).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/fs/src/symlink_dir.rs 78.57% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13009   +/-   ##
=======================================
  Coverage   85.53%   85.53%           
=======================================
  Files         498      498           
  Lines       79541    79551   +10     
=======================================
+ Hits        68037    68046    +9     
- Misses      11504    11505    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI review requested due to automatic review settings July 14, 2026 23:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/fs/src/symlink_dir.rs`:
- Around line 411-440: Update the rename-failure handling around fs::rename so
cleanup and symlink_metadata errors never return before the existence check or
mask the original rename_error. Attempt fs::remove_dir, retain any cleanup
failure for reporting only, always run symlink_metadata(link) to return
AlreadyExists when the destination exists, and otherwise return an error that
preserves rename_error while incorporating relevant cleanup or metadata details.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8393006e-072d-40e3-9301-f2c925457ce8

📥 Commits

Reviewing files that changed from the base of the PR and between 8975e14 and d1be168.

📒 Files selected for processing (2)
  • .changeset/windows-atomic-junctions.md
  • pnpm/crates/fs/src/symlink_dir.rs

Comment thread pnpm/crates/fs/src/symlink_dir.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread pnpm/crates/fs/src/symlink_dir.rs Resolved
Comment thread pnpm/crates/fs/src/symlink_dir/tests.rs Resolved
Comment thread pnpm/crates/fs/src/symlink_dir.rs Resolved
Copilot AI review requested due to automatic review settings July 15, 2026 00:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 15, 2026 01:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/pacquet-ci.yml Resolved
Comment thread pnpm/crates/fs/src/symlink_dir.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 15, 2026 19:52
@zkochan
zkochan force-pushed the fix/windows-global-store-symlinks branch from 939bb7d to 62daba3 Compare July 15, 2026 19:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset only declares a pacquet bump and omits an explicit pnpm entry. This violates
the changeset compliance requirement and may cause incorrect/absent versioning for pnpm in release
tooling.
Code

.changeset/windows-atomic-junctions.md[R1-3]

+---
+"pacquet": patch
+---
Evidence
PR Compliance ID 713436 requires each added/modified changeset to explicitly include the pnpm
package with a valid bump type (patch/minor/major). The changeset front-matter shown only
contains "pacquet": patch and no pnpm entry.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/windows-atomic-junctions.md[1-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset `.changeset/windows-atomic-junctions.md` is missing an explicit `pnpm` package entry (with a valid bump type), which is required by the compliance checklist.

## Issue Context
This PR adds a new changeset, but its front-matter only lists `pacquet`.

## Fix Focus Areas
- .changeset/windows-atomic-junctions.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Global junction commit mutex 🐞 Bug ➹ Performance
Description
On Windows junction fallback, windows::create_junction takes a single process-wide Mutex across
destination inspection and rename, so unrelated junction creations contend and the commit phase
cannot run in parallel. This can noticeably reduce parallel install/hoist throughput on Windows
because callers already parallelize symlink creation work.
Code

pnpm/crates/fs/src/symlink_dir.rs[R367-381]

+    static JUNCTION_STAGING_ID: AtomicU64 = AtomicU64::new(0);
+    static JUNCTION_COMMIT_LOCK: Mutex<()> = Mutex::new(());

    pub fn create(original: &Path, link: &Path) -> io::Result<()> {
        match MODE.load(Ordering::Relaxed) {
-            USE_SYMLINK => create_true_symlink(original, link),
-            USE_JUNCTION => junction::create(original, link),
+            USE_SYMLINK => match create_true_symlink(original, link) {
+                Err(error) if should_fallback_to_junction(&error) => {
+                    create_and_cache_junction(original, link)
+                }
+                result => result,
+            },
+            USE_JUNCTION => create_junction(original, link),
            _ => probe_and_cache(original, link),
        }
    }
Evidence
create_junction uses a single static JUNCTION_COMMIT_LOCK and holds it while performing
destination inspection and rename, which serializes commit phases across all junction creations
in-process. At the same time, the package manager’s hoist phase explicitly runs
pacquet_fs::symlink_dir calls in parallel, and the direct-dependency linker treats symlink
creation as a hot path (thousands per install), so this contention is directly on a
performance-sensitive path when Windows falls back to junctions.

pnpm/crates/fs/src/symlink_dir.rs[366-472]
pnpm/crates/package-manager/src/hoist.rs[597-626]
pnpm/crates/package-manager/src/symlink_package.rs[58-64]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`create_junction()` serializes the commit phase (destination inspection + rename and some cleanup paths) for **all** junction creations under one global mutex. This unnecessarily couples unrelated link destinations and can reduce throughput in link-heavy parallel phases.

### Issue Context
- Staging junction creation happens outside the lock, but the commit phase still includes filesystem I/O (`symlink_metadata`, `rename`, and some `remove_dir`) while holding a global lock.
- Some call sites (e.g. hoist) intentionally perform symlink creation in parallel; the global mutex limits the parallel scalability when junction mode is active.

### Fix approach (choose one)
1) **Remove the global lock entirely** and rely on atomic `rename` + error handling (treat `AlreadyExists` as the concurrency signal and cleanup staging afterwards).
2) **Replace the single global lock with finer-grained locking**, e.g. a small set of striped mutexes keyed by a stable hash of `link` (or per-parent directory), so unrelated links can commit concurrently.
3) **Narrow the critical section**: hold the lock only around the minimal rename/existence decision, and perform staging cleanup (`remove_dir`) outside the lock where possible.

### Fix Focus Areas
- pnpm/crates/fs/src/symlink_dir.rs[366-520]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ  1 issues published inline · 2 in summary

Qodo Logo

Comment on lines +1 to +3
---
"pacquet": patch
---

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Changeset missing pnpm entry 📘 Rule violation § Compliance

The new changeset only declares a pacquet bump and omits an explicit pnpm entry. This violates
the changeset compliance requirement and may cause incorrect/absent versioning for pnpm in release
tooling.
Agent Prompt
## Issue description
The changeset `.changeset/windows-atomic-junctions.md` is missing an explicit `pnpm` package entry (with a valid bump type), which is required by the compliance checklist.

## Issue Context
This PR adds a new changeset, but its front-matter only lists `pacquet`.

## Fix Focus Areas
- .changeset/windows-atomic-junctions.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

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

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants