-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(core): optimize daemon server hot paths #33738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(core): optimize daemon server hot paths #33738
Conversation
Optimize sync-generators.ts: - Replace O(n²) .every() check with Set for O(1) lookup in processConflictingGenerators - Remove intermediate Set creation in collectAndScheduleSyncGenerators Optimize outputs-tracking.ts: - Reduce dirname() calls by 50% (calculate once per iteration instead of twice) - Add early exit for disabled check before expensive normalization - Make normalizeOutputs synchronous (underlying FFI call is sync) - Replace new Date().getTime() with Date.now() for consistency
👷 Deploy request for nx-docs pending review.Visit the deploys page to approve it
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
View your CI Pipeline Execution ↗ for commit 5edc9bc
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nx Cloud has identified a possible root cause for your failed CI:
Our daemon server performance optimizations are unrelated to this Gradle e2e test failure. The test is failing due to Gradle's toolchain auto-provisioning attempting to download Java 21 from the foojay.io API, which returns a malformed JDK archive that "does not contain a Java home." This is an external service/environment configuration issue requiring infrastructure fixes, not code changes.
No code changes were suggested for this issue.
If the issue was transient, you can trigger a rerun by pushing an empty commit:
git commit --allow-empty -m "chore: trigger rerun"
git push
🎓 Learn more about Self-Healing CI on nx.dev
Current Behavior
The daemon server has several performance inefficiencies in hot paths:
sync-generators.ts
O(n²) Conflict Detection (lines 322-331)
For each of n results,
.every()iterates m conflict results = O(n*m)Redundant Set Creation (lines 113-119)
Creates intermediate Set only to iterate it once.
outputs-tracking.ts
Redundant dirname() calls (lines 19-26, 87-92)
dirname()is called twice per iteration.Late disabled check
Expected Behavior
Complexity Improvements
Early Exit Optimization
Changes Made
sync-generators.ts
Setfor O(1) lookup inprocessConflictingGeneratorsinstead of O(n).every()Setcreation incollectAndScheduleSyncGeneratorsoutputs-tracking.ts
dirname()once per iteration, reuse resultdisabledcheck before expensivenormalizeOutputs()callnormalizeOutputssynchronous (underlyinggetFilesForOutputsis sync FFI)Date.now()instead ofnew Date().getTime()Test Plan
pnpm jest packages/nx/src/daemon/server/sync-generators.spec.ts- 1 test passespnpm jest packages/nx/src/daemon/server/outputs-tracking.spec.ts- 5 tests passRelated Issue(s)
Contributes to #32265, #33263
Merge Dependencies
This PR has no dependencies and can be merged independently.
Must be merged BEFORE: #33748