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

Prerender takes 10 minutes per page!!! #2449

Closed
Neo-Zhixing opened this issue Nov 27, 2023 · 2 comments · Fixed by #2527
Closed

Prerender takes 10 minutes per page!!! #2449

Neo-Zhixing opened this issue Nov 27, 2023 · 2 comments · Fixed by #2527

Comments

@Neo-Zhixing
Copy link

Neo-Zhixing commented Nov 27, 2023

Environment


  • Operating System: Linux
  • Node Version: v20.9.0
  • Nuxt Version: 3.8.2
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.0
  • Package Manager: pnpm@8.10.2
  • Builder: -
  • User Config: devtools, extends, css, modules, site, sitemap, nitro
  • Runtime Modules: @nuxt/content@2.9.0-28344318.76dc891, @nuxt/ui@2.10.0-28344386.15a40f5, nuxt-simple-sitemap@4.1.6
  • Build Modules: -

Reproduction

To test this, download this zip file: https://neo-zhixing.github.io/vk-doc-md/dist.zip and put it in ./content/man

Then, create a new module to populate the prerendering routes

import { readdir } from 'fs/promises';

export default defineNuxtModule({
    async setup(_, nuxt) {
        // Set the code highlight configurations
        nuxt.options.nitro.prerender = nuxt.options.nitro.prerender  {};
        nuxt.options.nitro.prerender.routes = nuxt.options.nitro.prerender.routes  [];
        const routes = new Set(nuxt.options.nitro.prerender.routes);

        const results = await readdir('./content/man');
        for (const filename of results) {
            routes.add('/man/' + filename.slice(0, -3));
        }
        nuxt.options.nitro.prerender.routes = Array.from(routes);
    }
})

Describe the bug

Prerendering 2000+ markdown pages take 26s per page locally. On vercel this takes 10s per page

image

Adding 20ish longer documents and this becomes 10 minutes PER PAGE.

image

What does this mean? It means that your page generation is O(n) to the amount of content. Total prerender time is O(n^2) to the amount of content you have.

This makes nuxt-content unsuitable for anything non-trivial when you have more than 1000 documents.

Removing half the pages and the per-page rendering time reduce by half.

Additional context

No response

Logs

No response

@Neo-Zhixing Neo-Zhixing changed the title Prerender is O(n^2) to the number of markdown document Prerender takes 10 minutes per page!!! Nov 28, 2023
@kakkokari-gtyih
Copy link

Related to #2476

@kakkokari-gtyih
Copy link

kakkokari-gtyih commented Dec 27, 2023

I'm experiencing the same problem (ref: misskey-dev/misskey-hub-next#72).
My project has 3000+ markdown documents and it takes about 30 seconds to generate each page on Cloudflare Pages.


  • Operating System: Windows_NT
  • Node Version: v18.18.0
  • Nuxt Version: 3.9.0
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: pnpm@8.12.1
  • Builder: -
  • User Config: runtimeConfig, css, modules, app, content, i18n, colorMode, postcss, alias, vite, nitro, hooks, experimental, routeRules
  • Runtime Modules: @nuxt/content@2.10.0, @nuxtjs/i18n@8.0.0, @nuxtjs/color-mode@3.3.2
  • Build Modules: -

image

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 a pull request may close this issue.

2 participants