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

chore: replace @babel/register with esbuild-wasm #5180

Merged
merged 12 commits into from
Feb 15, 2023

Conversation

merceyz
Copy link
Member

@merceyz merceyz commented Jan 7, 2023

What's the problem this PR addresses?

Running Yarn from sources is a bit slow.

Ref #2228

How did you fix it?

Replaced @babel/register with a custom setup using esbuild-wasm

Results

Benchmark 1: esbuild-cache
  Time (mean ± σ):      4.099 s ±  0.010 s    [User: 4.920 s, System: 0.399 s]
  Range (min … max):    4.087 s …  4.115 s    10 runs

Benchmark 2: esbuild-no-cache
  Time (mean ± σ):      6.133 s ±  0.036 s    [User: 5.415 s, System: 0.448 s]
  Range (min … max):    6.088 s …  6.199 s    10 runs

Benchmark 3: esbuild-partial-cache
  Time (mean ± σ):      5.009 s ±  0.030 s    [User: 5.216 s, System: 0.417 s]
  Range (min … max):    4.975 s …  5.067 s    10 runs

Benchmark 4: babel-cache
  Time (mean ± σ):      6.223 s ±  0.130 s    [User: 7.957 s, System: 0.646 s]
  Range (min … max):    6.076 s …  6.538 s    10 runs

Benchmark 5: babel-no-cache
  Time (mean ± σ):     11.243 s ±  0.036 s    [User: 16.104 s, System: 0.764 s]
  Range (min … max):   11.195 s … 11.291 s    10 runs

Benchmark 6: babel-partial-cache
  Time (mean ± σ):      7.155 s ±  0.048 s    [User: 9.816 s, System: 0.660 s]
  Range (min … max):    7.092 s …  7.254 s    10 runs

Summary
  'esbuild-cache' ran
    1.22 ± 0.01 times faster than 'esbuild-partial-cache'
    1.50 ± 0.01 times faster than 'esbuild-no-cache'
    1.52 ± 0.03 times faster than 'babel-cache'
    1.75 ± 0.01 times faster than 'babel-partial-cache'
    2.74 ± 0.01 times faster than 'babel-no-cache'

Checklist

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@merceyz merceyz force-pushed the merceyz/chore/esbuild-dev branch 2 times, most recently from c69dc83 to 782532d Compare February 4, 2023 14:38
@merceyz merceyz changed the title chore: use esbuild for running sources chore: replace @babel/register with esbuild Feb 4, 2023
@merceyz merceyz changed the title chore: replace @babel/register with esbuild chore: replace @babel/register with esbuild-wasm Feb 4, 2023
@merceyz merceyz marked this pull request as ready for review February 4, 2023 17:05
@merceyz merceyz marked this pull request as draft February 5, 2023 00:28
@merceyz merceyz marked this pull request as ready for review February 5, 2023 10:54
@merceyz merceyz marked this pull request as draft February 6, 2023 09:35
@merceyz merceyz marked this pull request as ready for review February 6, 2023 21:20
A fresh cache is 2212kB for 263 files so unlikely to become a problem.
Runtime performance is roughly the same but the cache size shrinks:
```diff
$ du -s node_modules/.cache/yarn/
- 2212    node_modules/.cache/yarn/
+ 1464    node_modules/.cache/yarn/
```
@arcanis
Copy link
Member

arcanis commented Feb 15, 2023

Significantly faster indeed, nice!

arcanis
arcanis previously approved these changes Feb 15, 2023
@arcanis arcanis enabled auto-merge (squash) February 15, 2023 12:11
@arcanis arcanis merged commit 8e2028e into master Feb 15, 2023
@arcanis arcanis deleted the merceyz/chore/esbuild-dev branch February 15, 2023 13:29
@merceyz merceyz mentioned this pull request Jul 15, 2023
3 tasks
github-merge-queue bot pushed a commit that referenced this pull request Oct 19, 2023
**What's the problem this PR addresses?**
<!-- Describe the rationale of your PR. -->
<!-- Link all issues that it closes. (Closes/Resolves #xxxx.) -->

#5180 replaced `@babel/register` with `esbuild` but the docs were not
updated

**How did you fix it?**
<!-- A detailed description of your implementation. -->

Update docs accordingly

**Checklist**
<!--- Don't worry if you miss something, chores are automatically
tested. -->
<!--- This checklist exists to help you remember doing the chores when
you submit a PR. -->
<!--- Put an `x` in all the boxes that apply. -->
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).

<!-- See
https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released
for more details. -->
<!-- Check with `yarn version check` and fix with `yarn version check
-i` -->
- [x] I have set the packages that need to be released for my changes to
be effective.

<!-- The "Testing chores" workflow validates that your PR follows our
guidelines. -->
<!-- If it doesn't pass, click on it to see details as to what your PR
might be missing. -->
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
merceyz added a commit that referenced this pull request Dec 25, 2023
* chore: use esbuild for running sources

* deps: update esbuild

* chore: remove babel setup

* refactor: only use builtin sourcemap support

* refactor: remove weekly cache pruning

A fresh cache is 2212kB for 263 files so unlikely to become a problem.

* fix: disable dynamic imports

* chore: workaround issue on windows

* fix: support node nightly

* chore: link to issues

* perf: use brotli

Runtime performance is roughly the same but the cache size shrinks:
```diff
$ du -s node_modules/.cache/yarn/
- 2212    node_modules/.cache/yarn/
+ 1464    node_modules/.cache/yarn/
```

* Minor stylistic tweaks

---------

Co-authored-by: Maël Nison <[email protected]>
(cherry picked from commit 8e2028e)
merceyz added a commit that referenced this pull request Dec 25, 2023
* chore: use esbuild for running sources

* deps: update esbuild

* chore: remove babel setup

* refactor: only use builtin sourcemap support

* refactor: remove weekly cache pruning

A fresh cache is 2212kB for 263 files so unlikely to become a problem.

* fix: disable dynamic imports

* chore: workaround issue on windows

* fix: support node nightly

* chore: link to issues

* perf: use brotli

Runtime performance is roughly the same but the cache size shrinks:
```diff
$ du -s node_modules/.cache/yarn/
- 2212    node_modules/.cache/yarn/
+ 1464    node_modules/.cache/yarn/
```

* Minor stylistic tweaks

---------

Co-authored-by: Maël Nison <[email protected]>
(cherry picked from commit 8e2028e)
merceyz added a commit that referenced this pull request Dec 25, 2023
* chore: use esbuild for running sources

* deps: update esbuild

* chore: remove babel setup

* refactor: only use builtin sourcemap support

* refactor: remove weekly cache pruning

A fresh cache is 2212kB for 263 files so unlikely to become a problem.

* fix: disable dynamic imports

* chore: workaround issue on windows

* fix: support node nightly

* chore: link to issues

* perf: use brotli

Runtime performance is roughly the same but the cache size shrinks:
```diff
$ du -s node_modules/.cache/yarn/
- 2212    node_modules/.cache/yarn/
+ 1464    node_modules/.cache/yarn/
```

* Minor stylistic tweaks

---------

Co-authored-by: Maël Nison <[email protected]>
(cherry picked from commit 8e2028e)
Woodpile37 pushed a commit to Woodpile37/berry that referenced this pull request Jan 10, 2024
* chore: use esbuild for running sources

* deps: update esbuild

* chore: remove babel setup

* refactor: only use builtin sourcemap support

* refactor: remove weekly cache pruning

A fresh cache is 2212kB for 263 files so unlikely to become a problem.

* fix: disable dynamic imports

* chore: workaround issue on windows

* fix: support node nightly

* chore: link to issues

* perf: use brotli

Runtime performance is roughly the same but the cache size shrinks:
```diff
$ du -s node_modules/.cache/yarn/
- 2212    node_modules/.cache/yarn/
+ 1464    node_modules/.cache/yarn/
```

* Minor stylistic tweaks

---------

Co-authored-by: Maël Nison <[email protected]>
(cherry picked from commit 8e2028e)
arcanis pushed a commit that referenced this pull request Jul 1, 2024
**What's the problem this PR addresses?**

We use esbuild to build and run Yarn from sources but not for our test
files.

Follow-up to #5180

**How did you fix it?**

Use esbuild to transpile files in our testing setup.

**Checklist**
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).
- [x] I have set the packages that need to be released for my changes to
be effective.
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants