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

Vite plugin: babel transform performance issue #68

Open
hoongtong opened this issue Apr 3, 2024 · 3 comments
Open

Vite plugin: babel transform performance issue #68

hoongtong opened this issue Apr 3, 2024 · 3 comments
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided

Comments

@hoongtong
Copy link

Environment

wyw-in-js version: v0.5.0
node: v20.10.0
OS: MacOS v14.2.1 (23C71)
Bundler: vite v5.2.6

Description

When updating the vite plugin from @linaria/vite v5.0.4 to @wyw-in-js/vite v0.5.0 we noticed a huge degradation in performance. When profiling the vite build we found that the babel transform took approximately 30s using the new plugin, while it was near negligible with the old one. Below you can see the different in the cpuprofiles between the plugins.

Using wyw-in-js:
image
Using linaria:
image

Here is our vite.config.ts:

 linaria({
        babelOptions: {
          presets: ["@babel/preset-typescript", "@babel/preset-react"],
        },
        exclude: ["node_modules"],
        include: ["**/*.{tsx,jsx}"],
      }),

Did anyone else experience this too? I don't immediately see any changes in the babel configuration that could be the cause. We have one very large codegen .ts files (77k lines)

@hoongtong hoongtong added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Apr 3, 2024
@github-actions github-actions bot removed the needs: triage 🏷 Issue needs to be checked and prioritized label Apr 3, 2024
@Anber
Copy link
Owner

Anber commented Apr 4, 2024

Hi @hoongtong
May I ask you to run both builds with { debug: { dir: "debug-info", print: true } } in linaria/wyw plugin's config and publish By method section from the log? It should look like

By method:
  createEntrypoint: 3365ms
  parseFile: 1482ms
  transform:evaluator: 1326ms
  transform:preeval: 7148ms
  transform:preeval:processTemplate: 1627ms
  transform:preeval:removeDangerousCode: 1236ms

@hoongtong
Copy link
Author

Thanks for the quick response, here's the timings of
@linaria/vite v5.0.4

Timings:
Total: 68894ms

By method:
  createEntrypoint: 4135ms
  parseFile: 1858ms
  transform:evaluator: 513ms
  transform:preeval: 21600ms
  transform:preeval:processTemplate: 11197ms
  transform:preeval:removeDangerousCode: 4361ms

Memory usage: {
  rss: 1303511040,
  heapTotal: 2850275328,
  heapUsed: 2778737384,
  external: 83556834,
  arrayBuffers: 2697994
}

@wyw-in-js/vite v0.5.0

Timings:
Total: 121885ms

By method:
  createEntrypoint: 1938ms
  parseFile: 2564ms
  transform:evaluator: 48097ms
  transform:preeval: 43592ms
  transform:preeval:processTemplate: 7631ms
  transform:preeval:removeDangerousCode: 9725ms

Memory usage: {
  rss: 1528971264,
  heapTotal: 2483060736,
  heapUsed: 2400392600,
  external: 81798423,
  arrayBuffers: 964627
}

A lot of time is spent in the evaluator step of the transform compared to the older version.

@o-alexandrov

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided
Projects
None yet
Development

No branches or pull requests

3 participants