Skip to content
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

update Nx, Turbo, Lage #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ Thumbs.db

.turbo
turbo-build.log

.nx/cache
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

/dist
/coverage

/.nx/cache
27 changes: 10 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,26 @@ ordinary. And, the bigger the repo, the bigger the difference in performance bet
The repo has Nx, Turbo, and Lage enabled. They don't affect each other. You can remove one without affecting the
other one.

## Benchmark & Results (May 31)
## Benchmark & Results (Dec 2023)

`npm run benchmark` runs the benchmark. The following numbers produced by an M1Max MBP. On a Windows machine all the tools will get slower, and the delta between Nx and Turbo/Lage will get bigger.

* **average nx time is: 149.3**
* **average turbo time is: 907.3**
* **average lage time is: 1084.4**
* **nx is 6.08x faster than turbo**
* **nx is 7.26x faster than lage**

Numbers from May 19:

* average nx time is: 172.8
* average turbo time is: 1134.1
* average lage time is: 1109.9
`npm run benchmark` runs the benchmark. The following numbers produced by an M1Pro MBP. On a Windows machine all the tools will get slower, and the delta between Nx and Turbo/Lage will get bigger.

- **average lage time is: 1189.5**
- **average turbo time is: 984.8**
- **average nx time is: 189.9**
- **nx is 6.263823064770932x faster than lage**
- **nx is 5.185887309110058x faster than turbo**

### Why is Nx faster than Turbo

Nx uses several optimizations to minimize the amount of computation required. For instance, it stores information about
Nx uses several optimizations to minimize the amount of computation required. For instance, it stores information about
the repository on disk to be able to recompute only what is needed. It runs a daemon process that gets all the necessary
data structures ready before the developer invokes a command. And the data structures are updated incrementally, usually
in just a few milliseconds.

Is Nx always faster? No. The performance sensitive parts of Nx are written in Rust, but it is all wrapped into a Node.js
process. Loading Node.js takes about 70ms (on a mac), regardless of what you do. You build 1000 projects, takes 70ms.
You build 1 project, it takes 70ms. If you have a repo with say 10 files in it, running Turbo will likely be faster
process. Loading Node.js takes about 70ms (on a mac), regardless of what you do. You build 1000 projects, takes 70ms.
You build 1 project, it takes 70ms. If you have a repo with say 10 files in it, running Turbo will likely be faster
because it boots faster.

Yarn, npm, pnpm have a similar boot time to Nx, and folks don't mind. And, of course, it's worth asking whether a
Expand Down
19 changes: 6 additions & 13 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
{
"extends": "nx/presets/npm.json",
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": [
"build"
],
"parallel": 3
}
}
},
"targetDefaults": {
"build": {
"outputs": ["{projectRoot}/.next"]
"outputs": [
"{projectRoot}/.next"
],
"cache": true
}
}
},
"parallel": 3
}
Loading