Commit graph

34 commits

Author SHA1 Message Date
Will Binns-Smith
e4f92b7206 Automatic downleveling to browser targets using swc_preset_env (vercel/turbo#380)
Closes vercel/turbo#440

This uses swc's preset_env to automatically downlevel code according to the environment's browser targets, and sets next-dev to use a limited, modern target.

To do:
* [x] Add snapshot test
* [x] turbotrace test failures — looks like this has something to do with the Buffer module? Hitting swc's "multiple constructors" not implemented: f655488cfa/crates/swc_ecma_transforms_compat/src/es2015/classes/mod.rs (L545)
* [x] ~Benchmark downleveling node_modules (probably on front) and make a decision re: downleveling everything vs. just workspaces~ Filed as vercel/turbo#457
2022-10-07 06:54:21 +00:00
LongYinan
402c64be00 Introduce AssetContent to handle symlink assets (vercel/turbo#406)
* Fix DiskFileSystem::read_link

* pnpm-like integration test

* Introduce AssetContent to handle symlink assets

* Fix read_link on Windows

* Run clippy fix

* Rename `path` to `target`

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>

* Split Windows specified code

* Add comments about Redirect is only represent Directory

* Handle symlink while reading content

* Clippy fix

* Revert previous changes in FileSystemPathVc::get_type

* Fix Unix read_link

* cleanup

* handle symlink while resolving native bindings

* Make LinkContent::Link contains only target

* Add LinkType to represent link type

* Cleanup VersionedAsset

* Cleanup LinkType

* Normalize the LinkContent::target

* Comments

* Revert special case workaround for sharp on Windows

* comments

* node_native_binding follow file link

* Apply CR suggestion

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2022-09-28 22:44:32 +08:00
Tobias Koppers
3263f5e5e6 replace json with serde_json (vercel/turbo#398)
get rid of `json` in favor of only `serde_json` for consistency and less dependencies
2022-09-28 09:02:40 +00:00
LongYinan
b9c36e7748 Align eslint and prettier rules with turborepo (vercel/turbo#397) 2022-09-20 07:33:15 +00:00
Tobias Koppers
a9b5ada56a fail-safe bindings code for SSR (vercel/turbo#391) 2022-09-19 19:11:14 +02:00
Tobias Koppers
1f7df032e2 benchmarks need more time and skip faster when failing (vercel/turbo#393) 2022-09-19 19:01:18 +02:00
Tobias Koppers
65be8a0804 handle exceptions during waiting for events (vercel/turbo#383) 2022-09-19 15:22:05 +00:00
Alex Kirszenberg
e35ad2f2dc Use React.memo in the test/bench app (vercel/turbo#384)
With React.memo:
```
bench_hmr_to_commit/Turbopack CSR/30000 modules
                        time:   [50.608 ms 51.659 ms 52.553 ms]
```

Without React.memo:
```
bench_hmr_to_commit/Turbopack CSR/30000 modules
                        time:   [853.47 ms 1.0191 s 1.1873 s]
                        change: [+1543.4% +1872.7% +2207.8%] (p = 0.00 < 0.05)
                        Performance has regressed.
```

Since we're only ever editing the top-level triangle in our HMR benchmarks, we're incurring the time it takes for React to re-render the whole tree, which is a function of the number of components in said tree. By using `React.memo`, we can skip updating children components during HMR.
2022-09-19 15:00:22 +00:00
Tobias Koppers
00b7a92a39 measure HMR to eval and HMR to commit independent from each other (vercel/turbo#382)
HMR to commit include react-refresh time to apply the update in the react component tree
2022-09-19 14:48:18 +02:00
Tobias Koppers
6d1a83384a Benchmark summarize script, workflow and stability (vercel/turbo#381) 2022-09-19 09:24:55 +00:00
Tobias Koppers
86f1831b06 fix compare action (vercel/turbo#373) 2022-09-16 08:06:54 +02:00
Tobias Koppers
22e996b90c ensure that HMR is really happening while measuring (vercel/turbo#365)
no need to test all module counts
2022-09-15 09:54:07 +00:00
Tobias Koppers
f4e28a07ef enable react refresh for vite (vercel/turbo#364)
It was doing a full refresh before
2022-09-15 00:04:49 +00:00
Tobias Koppers
826998cf07 increase benchmark timeouts to be able to benchmark larger module counts (vercel/turbo#362) 2022-09-14 23:17:14 +00:00
Will Binns-Smith
eb93985d95 Benchmarks: allow simultaneously installing multiple packages from npm (vercel/turbo#339)
Previously, we ran multiple `npm install` operations in serial using multiple calls to `install_from_npm`. Instead, this allows us to express dependencies all at once as a single command to the npm cli, which should reduce the time we spend installing from npm and updating package.json.

Test Plan: Manually confirmed that package.json was updated correctly.  `cargo bench`.
2022-09-12 12:34:26 -07:00
Will Binns-Smith
aaa640def6 Benchmark Webpack (vercel/turbo#338)
This adds webpack 5 to the benchmark suite.

Test Plan: Manually confirmed package.json updates and webpack config written to temp dir correctly. `cargo bench`.
2022-09-12 11:09:26 -07:00
Will Binns-Smith
361ca5eca8 Split benchmark code into more modules (vercel/turbo#337)
This splits the benchmark code into more modules. Notes:

* ~Moved/left `get_bundlers()` and `get_module_counts()` to/in mod.rs. In particular, moving `get_bundlers()` to either bundle.rs or util.rs would lead to a circular dependency. These both also rely on env var configuration, so I figured this was a reasonable place for them.~
* The Bundler trait has its own module (not moved to util), since it's a top-level concern and not really a miscellaneous utility.
* Each bundler has its own module file.

Test Plan: `TURBOPACK_BENCH_BUNDLERS=all cargo test --benches -p next-dev -- --nocapture` and verify same output as before change.
2022-09-09 16:35:12 -07:00
Tobias Koppers
ecaf59b3e6 improve startup metric measurement (vercel/turbo#331)
This fixes the `startup` benchmark metric to show the time until first render, instead of being equal to hydration.

It also skips `hydration` for CSR bundlers since it's equal first render for them.

It now correctly measures the initial SSR as `startup`, so CLI start until page visible:
![image](https://user-images.githubusercontent.com/1365881/189152420-396b181b-5a3e-4902-881d-7c247fa43bd8.png)
2022-09-08 16:00:15 +00:00
Alex Kirszenberg
0a112ccb14 Fix Next.js 11 React version (vercel/turbo#333) 2022-09-08 15:18:53 +00:00
Tobias Koppers
378adc7112 cleanup nitpicks (vercel/turbo#330) 2022-09-08 14:54:09 +00:00
Tobias Koppers
6f312afedc allow to pass module counts list via env var (vercel/turbo#332)
add custom benchmark workflow

run large counts in CI
2022-09-08 16:46:19 +02:00
Alex Kirszenberg
a45572b642 Ensure pages close before app does (vercel/turbo#329) 2022-09-08 15:02:48 +02:00
Alex Kirszenberg
6f0fc67cab Stop processes gracefully when possible, add drop guard to pages (vercel/turbo#328) 2022-09-08 12:00:19 +00:00
Will Binns-Smith
dd217c71b9 Benchmark Parcel (vercel/turbo#322)
* Benchmark Parcel

* add Parcel to the CI benchmarks

* move some turbopack dependencies to the bundler as they conflict with other bundlers

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-09-08 13:08:25 +02:00
Will Binns-Smith
abcdd78623 Benchmark Next.js 11 and 12 (vercel/turbo#304)
This implements benchmark support for Next.js 12. Next.js (the tool) expects to be able to resolve from the `next` package in the cwd, so it must be installed alongside the other node_modules in the test.  `prepare` was added to the Bundler trait to handle this case.

Test Plan: `TURBOPACK_BENCH_ALL=all cargo bench -p next-dev`


Co-authored-by: Alex Kirszenberg <1621758+alexkirsz@users.noreply.github.com>
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2022-09-08 05:00:32 +00:00
Will Binns-Smith
12e5f19a84 Benchmark against Vite (vercel/turbo#299)
This adds a comparison against Vite to our benchmark suite, running the startup, change, and restart benchmarks.

Test Plan: `cargo bench`


Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2022-09-07 00:09:06 +00:00
Tobias Koppers
b78ede6099 fix benchmark compare actions (vercel/turbo#318)
The benchmark github action didn't correctly copy and use the executables used in benchmarks via CARGO_BIN_EXE_*.

This adds a CARGO_BIN_EXE_* runtime override to the github action to allow to use correct executable.

It will show correct results for next-dev benchmarks too, e. g. here an example of reverting vercel/turbo#295 
![image](https://user-images.githubusercontent.com/1365881/188696769-d393cd45-b08f-4fd5-ad69-2d38a54bcd92.png)
2022-09-06 17:34:51 +00:00
Will Binns-Smith
aab23b38da Parameterize devserver used in benchmarks (vercel/turbo#298)
This implements the basics of parameterizing the tool/devserver used in these tests. Following PRs will implement benchmarking of Vite, bun, Parcel, etc.

Test Plan: `cargo bench -p next-dev` and verify no change in performance.
2022-09-06 09:39:11 +00:00
Will Binns-Smith
7d79ce5029 Benchmark restart time for dev server (vercel/turbo#244)
This implements a benchmark of restarting the devserver after successfully starting it and shutting it down.

## Question/TODO: 

Since our goal is metrics that don't scale with project size, should we
assert that the small/medium benchmark results don't differ?

Test Plan: `cargo bench -p next-dev`
2022-09-06 08:30:08 +00:00
Will Binns-Smith
80d0a86655 Basic change bench for dev server (vercel/turbo#297)
This builds on vercel/turbo#240, starting up a server and then benchmarking the response to a small file change.

This change does not introduce nor remove any dependencies. A followup
benchmark should do so.

Test Plan: cargo bench -p next-dev


Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2022-09-06 07:34:25 +00:00
Tobias Koppers
d78084a0b4 Test benchmark cases in separate job (vercel/turbo#311)
Move benchmark test into separate job and run them for windows and macOS too
2022-09-06 06:48:01 +00:00
Will Binns-Smith
43f25065c8 Benchmarks: assert that no runtime errors occur when loading pages (vercel/turbo#285)
This adds an assertion that no runtime (browser) errors occurred when
loading a benchmark page.

Test Plan: Temporarily removed the npm install for the test app and
verified the benchmark failed as the test app requires react, react-dom.
Restored the npm install and verified the benchmark runs to completion.
2022-08-29 16:18:26 -07:00
Will Binns-Smith
2ee6039ad0 Benchmarks: Install node_modules and reuse test directories (vercel/turbo#284)
This:

* Runs `npm install` in test directories to provide turbopack with modules necessary to bundle them.
* Reuses test directories for iterations across the given benchmark. This prevents unnecessary file writing and `npm install` for each iteration, improving the times to run benchmarks.

Currently cherry-picks vercel/turbo#278 as it's necessary along with vercel/turbo#277.

Test Plan: Connected to the running devserver mid-test and confirmed no errors are thrown and the triangle is rendered correctly.
2022-08-29 15:41:26 -07:00
Will Binns-Smith
e783ec8302 Benchmark startup time for bundling many modules (vercel/turbo#240)
* Basic startup bench for dev server

* fixes to benchmarking (vercel/turbo#268)

* use bench profile for benchmarking

* make setup and teardown not part of the measurement

add support for async setup and teardown

share browser between measurements

* updates for changes TestApp

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2022-08-24 11:36:08 -07:00