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

Drastic increase in build and warm up times when upgrading to 3.9.0 #25072

Closed
TimGuendel opened this issue Jan 5, 2024 · 16 comments
Closed

Drastic increase in build and warm up times when upgrading to 3.9.0 #25072

TimGuendel opened this issue Jan 5, 2024 · 16 comments

Comments

@TimGuendel
Copy link

Environment

- Operating System: Windows_NT
- Node Version:     v18.18.2
- Nuxt Version:     3.8.2
- CLI Version:      3.10.0
- Nitro Version:    2.8.1
- Package Manager:  yarn@3.6.4
- Builder:          -
- User Config:      telemetry, experimental, devtools, components, app, nitro, imports, vite, css, modules, pinia, image, proxy, runtimeConfig
- Runtime Modules:  @vueuse/nuxt@10.7.0, @pinia/nuxt@0.5.1, nuxt-jsonld@2.0.8, @nuxt-alt/proxy@2.4.9, @nuxt/image@1.1.0
- Build Modules:    -

Reproduction

I tried, but it does not really show with an empty project 🤔
3.8.2 https://stackblitz.com/edit/github-r32mz1-hj5c5o?file=package.json
3.9.0 https://stackblitz.com/github/nuxt/starter/tree/v3/?file=package.json

Describe the bug

My (large) project:
3.8.2:
image

3.9.0:
image

Switching back to 3.8.2 leads to the shorter loading times again.

Additional context

No response

Logs

No response

Copy link

stackblitz bot commented Jan 5, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

Copy link
Contributor

github-actions bot commented Jan 5, 2024

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz
👉 https://codesandbox.io/s/github/nuxt/starter/v3-codesandbox

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@manniL
Copy link
Member

manniL commented Jan 5, 2024

Would be nice to see if it is based on the amount of components or something else triggeres the high build time. Can you try to repro?

Without a repro I don't think we can do much here as it can be any kind of module or similar 🙈

@danielroe
Copy link
Member

We'd definitely want to tackle this if you can provide a reproduction.

Can you try installing vite v5 in your Nuxt 3.8.2 project, to see whether that's the cause? It should be completely compatible, but you'll need to use npm/pnpm/yarn resolutions/overrides.

@TimGuendel
Copy link
Author

We'd definitely want to tackle this if you can provide a reproduction.

Can you try installing vite v5 in your Nuxt 3.8.2 project, to see whether that's the cause? It should be completely compatible, but you'll need to use npm/pnpm/yarn resolutions/overrides.

I could not find any information on how to do this. Simply using "overrides": { "vite": "5.0.11" }, did not do anything.

  • How can I force Nuxt 3.8.2 to use Vite 5?
  • How can I make sure it is indeed using Vite 5?

@TimGuendel
Copy link
Author

TimGuendel commented Jan 8, 2024

All right, @manniL helped me 👍 (using resolutions instead of overrides did the trick 🤷‍♂️)

Vite 5 seems to be the culprit indeed:

image

@danielroe
Copy link
Member

It would be great to have a reproduction. Hopefully this is something we can solve in vite. 🙏

@danielroe
Copy link
Member

One thing - when you set vite.warmupEntry to false, this should disappear (as it disables the 'in-advance' warmup). I'd be interested to know, however, if your initial browser request to your site is a similar length of time.

@TimGuendel
Copy link
Author

One thing - when you set vite.warmupEntry to false, this should disappear (as it disables the 'in-advance' warmup). I'd be interested to know, however, if your initial browser request to your site is a similar length of time.

So I did some tests and took screenshots of the nitro console and the browser timeline in the network tab. I waited for all chunks to be loaded:

3.8.2 with warmupEntry true
image
image

3.8.2 with warmupEntry false
image
image

3.9.0 with warmupEntry true
image
image

3.9.0 with warmupEntry false
image
image

@danielroe
Copy link
Member

cc: @antfu would love your thoughts on this

@antfu
Copy link
Member

antfu commented Jan 9, 2024

From the glance I can't really tell what's the cause. I think we still need a minimal reproduction to move forward

@rolf-koizumi-ecdb
Copy link

rolf-koizumi-ecdb commented Jan 11, 2024

Sorry about my comment yesterday (which I deleted) - I didn't notice that one of my projects was modified, leading to false results.
I have debugged again, and these are my current findings, though I might have made mistakes again.

  • In our project with nuxt@3.9.1, warmup() is called for more urls than in nuxt@3.8.2.
  • The increased number of calls happen when isServer === false.
  • This return statement in warmup.ts is called way less in nuxt@3.9.1/vite@5.0.11 with isServer === false than in nuxt@3.8.2/vite@4.5.1.
    • For our project, in warmup() when env.isClient === true, vite@5.0.11 returns m.transformResult === null and m.transformResult === null for all modules, so this early return is never called.
    • With vite@4.5.1, m.transformResult.code sometimes has a value, so the return statement is called sometimes, leading to less iterations of warmup().

Alltogether, I have ~2104 calls of warmup() with nuxt@3.8.2 and ~5936 calls of warmup() with nuxt@3.9.1 which makes me think that maybe the increased number of calls is the sole reason for longer warmup times.
Though Nitro build time is 2331 ms vs. 32309 ms for me, so maybe there's more going on.

I tried looking into vites' server.moduleGraph.getModuleByUrl() but haven't found out where transformResult.code is set, what it represents and if anything has changed there.
And sorry for still not providing a minimal reproduction. If these sorts of debugging do not help I will concentrate more on getting a minimal reproduction.

@TimGuendel
Copy link
Author

Was this helpful at all, or is there something else I could try to help solving this issue? 🤔

@TimGuendel
Copy link
Author

TimGuendel commented Jan 24, 2024

@manniL suggested that I "empty" my templates and try again. We have +/-350 vue files and I replaced all templates by <template><div>Hello</div></template>

These are the startup times:

image image

Although significantly decreased, the build time with Nuxt 3.9.3 is almost double the time it took with Nuxt 3.8.2.
The warm up times also increased by a lot.

EDIT: I ended up stripping away most of the code, keeping "only" empty components. The built time got much better, but the warmup times were always worse with 3.9.3. So it appears that the number of files has a direct effect on the warmup time 🤔

@TimGuendel
Copy link
Author

So this issue seems to be resolved with 3.11.1... closing this.

Copy link
Member

Fantastic! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants