Skip to content

cleanup(core): cache compiled glob sets to avoid redundant recompilation#34602

Merged
FrozenPandaz merged 1 commit intomasterfrom
nxc-3960
Feb 25, 2026
Merged

cleanup(core): cache compiled glob sets to avoid redundant recompilation#34602
FrozenPandaz merged 1 commit intomasterfrom
nxc-3960

Conversation

@leosvelperez
Copy link
Copy Markdown
Member

Current Behavior

build_glob_set recompiles identical glob pattern sets on every call, even when the same set of patterns has been compiled before.

Expected Behavior

Compiled NxGlobSet instances are cached in a static DashMap keyed by sorted glob strings. Repeated calls with the same patterns return a shared Arc<NxGlobSet> instead of recompiling. Profiling nx run-many -t build lint test --parallel 8 in the Nx repo measured 95.6% cache hit rate (9,758 of 10,202 calls) with only 444 unique pattern sets, reducing hashing-phase CPU by ~40%.

Static DashMap cache keyed on sorted+joined globs eliminates
redundant glob compilation in build_glob_set. Profiled on this
repo with `nx run-many -t build lint test --parallel 8`
(NX_HASH_ONLY=true, N=10 runs): 10,202 total calls, 444 unique
patterns, 95.6% hit rate. cpu_user: 8011ms -> 4782ms (-40.3%),
wall: 2182ms -> 1898ms (-13.0%).
@leosvelperez leosvelperez requested review from a team as code owners February 25, 2026 15:36
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 25, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 9e73481
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/699f17027bd2e00008b67f6a
😎 Deploy Preview https://deploy-preview-34602--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 25, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 9e73481
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/699f17028d7c8600088066ed
😎 Deploy Preview https://deploy-preview-34602--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Feb 25, 2026

View your CI Pipeline Execution ↗ for commit 9e73481

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 55m 18s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3m 4s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 7s View ↗
nx-cloud record -- nx format:check ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-25 17:05:17 UTC

@leosvelperez leosvelperez self-assigned this Feb 25, 2026
@FrozenPandaz FrozenPandaz merged commit 12812dc into master Feb 25, 2026
24 checks passed
@FrozenPandaz FrozenPandaz deleted the nxc-3960 branch February 25, 2026 20:52
FrozenPandaz pushed a commit that referenced this pull request Feb 26, 2026
…ion (#34602)

## Current Behavior

`build_glob_set` recompiles identical glob pattern sets on every call,
even when the same set of patterns has been compiled before.

## Expected Behavior

Compiled `NxGlobSet` instances are cached in a static `DashMap` keyed by
sorted glob strings. Repeated calls with the same patterns return a
shared `Arc<NxGlobSet>` instead of recompiling. Profiling `nx run-many
-t build lint test --parallel 8` in the Nx repo measured 95.6% cache hit
rate (9,758 of 10,202 calls) with only 444 unique pattern sets, reducing
hashing-phase CPU by ~40%.

(cherry picked from commit 12812dc)
FrozenPandaz pushed a commit that referenced this pull request Feb 26, 2026
…ion (#34602)

## Current Behavior

`build_glob_set` recompiles identical glob pattern sets on every call,
even when the same set of patterns has been compiled before.

## Expected Behavior

Compiled `NxGlobSet` instances are cached in a static `DashMap` keyed by
sorted glob strings. Repeated calls with the same patterns return a
shared `Arc<NxGlobSet>` instead of recompiling. Profiling `nx run-many
-t build lint test --parallel 8` in the Nx repo measured 95.6% cache hit
rate (9,758 of 10,202 calls) with only 444 unique pattern sets, reducing
hashing-phase CPU by ~40%.

(cherry picked from commit 12812dc)
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 3, 2026

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants