-
Notifications
You must be signed in to change notification settings - Fork 923
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
[Bug report] Compiling & rendering too too too much slower than VitePress #994
Comments
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
@meteorlxy I have created a simple repo to test It has about
If build with full |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
Any update on this issue? |
This comment was marked as spam.
This comment was marked as spam.
I am focusing this issue these days. Vitepress loads markdown files directly through a converter, and there is no global "Pages" scope (access other page infomation from one page), which means that vitepress directly luanch a app. Meanwhile, vuepress have lifecyles, it's tranforming all markdown files to vue compoent and provides "pages data" to let plugins and theme proceed them, also, vuepress is registing all routes at start up and loads pages data with promises. Besides the structure, one of the reasons which slows down vuepress ssr speed is that we are transforming almost every packages when generating ssr: So that we will take more time to generate a ssr bundle before proceeing SSG. This is caused by pnpm support. |
@lslzl3000 Would you please run another test with your repo after we migrate to ESM? |
@meteorlxy I have a deeper dig in to our code, pageData only changes during router navigation, but SSG doesn't need those at all, so maybe it could be possible for us to stop loading the whole |
Hello, I'm looking for some solution as well. On my case I have around 2K posts and is impossible do a build, with 10GB on |
I used to bring up the issue of VuePress scalability on its GitHub repository (vuejs/vuepress#2689). In my project (https://github.com/openupm/openupm-next), I have around 3000 pages generated by a custom VuePress plugin's My project was initially built with VuePress v1, but I encountered some difficulties during a partial migration to VuePress v2 using For illustration, let's consider @lslzl3000's repository (https://github.com/lslzl3000/vuepressVSvitepress), which contains 914 markdown files, each having an average file size of 22KB. Conducting a quick test yielded the following results:
A few additional notes:
Let's double the page numbers by duplicating pages under the
My major takeaways are two points:
That is a bit counterintuitive - I assume the build time grows linearly with the number of pages, not the memory usage. The behavior is not friendly with large websites that rely on cloud-based build services (GitHub actions for example). We can suffer with more build time, but a large memory VM is usually very expensive or unnecessary for generating a static website with thousands of pages, think about a 10K page website that requires a 48 GB memory VM. After reading #1262 proposal, it seems hard to improve:
On the vite community it's also a hot topic: vitejs/vite#2433, I'm processing it slowly and hopefully find some clues. It seems a pitfall you're going hit when you grow to a larger scale, and the solution is not very obvious here. |
I also conducted a quick test on @hustcer's repository (https://github.com/nushell/nushell.github.io), which comprises 676 markdown files, each with an average file size of 6 KB. Here are the profiling results for the test:
The outcome is entirely acceptable. The primary distinction when compared with lslzl3000/vuepressVSvitepress is that the average markdown file size of nutshell.github.io is significantly smaller (22KB vs. 6 KB). This implies that before delving into vite bundle options, the most immediate area to address is reducing the overall project size. While this approach may not be suitable for a purely markdown-based VuePress site, it might prove beneficial for some dynamically generated pages. One potential strategy could be deferring the loading of heavy data to runtime, such as fetching a JSON file from the public folder. |
@favoyang Thanks for your investigation. Some problems of performance IMO:
I've been wanting to try these things for a while, but don't have enough time. TBH it should be faster after those changes, but it would also make VuePress more like VitePress. Thus I also don't have much motivation to do so. 😞 I have put a lot of effort into this project, although it is not perfect. I am grateful to have you who are still using this project. ❤️ |
@meteorlxy, I truly appreciate your consistent assistance. I am aware that the terms "performance" and "scalability" can have diverse meanings depending on the context. They may refer to:
In my previous comments, I addressed the first three aspects. Currently, my primary focus lies on the memory footprint, as it could potentially impede a smooth production build. By implementing the strategy of deferring the loading of heavy data to runtime and relocating large data from frontmatter to JSON files hosted at To clarify my use case further, envision a blog containing an extensive number of pages. The idea is to fetch and render markdown format content at runtime, catering to a scenario where the number of pages is substantial. Feedback on other ideas
If the auto sidebar is the sole feature that necessitates such extensive data processing, it could possibly be deferred for computation until later stages during runtime to exchange a better dev experience.
I'm not entirely sure about the extent to which this optimization has contributed to the build time. Although conducting optimizations is crucial, it's essential to run a benchmark on a sample project and analyze the results to ensure that everyone has a clear understanding of the impact. However, it seems the PR itself can also influence runtime performance, which could be a reasonable consideration.
My initial intuition about Static Site Generation (SSG) is that common parts of the website, such as the core functionality and layout, are bundled together during the build process. These common parts typically form the main framework of the website and are known as the "static core." On the other hand, the actual content and data of each page are treated as individual entities. These pages are analyzed and generated separately, resulting in specific JavaScript chunks for each page. These chunks are then loaded dynamically at runtime as needed. The beauty of this approach is that, regardless of how large the project grows in terms of content and pages, the build memory footprint remains relatively constant and does not scale with the size of the website. The build time, too, scales linearly with the number of pages or content items, which makes it an efficient and scalable solution for generating static sites. Perhaps my intuition is mistaken. That many details results in pushing all converted files to the vite compiler together - which drives more memory footprint scaled linearly with the number of pages. Once again, thank you for your unwavering dedication and hard work. While I might not be familiar with the internal details of VuePress and VitePress, one advantage of being an independent project is the ability to mold it according to your vision and goals. Every framework possesses its own set of strengths and weaknesses, and it's not necessary for one to perfectly align with another in all aspects. |
This comment was marked as spam.
This comment was marked as spam.
Updates here, we have a new pr which avoids heavy cost on This would speed up build and webpaage performance, but little on memory cost. |
Hello guys, I was able to enhance the performance of my builds significantly with Vitepress after implementing a few improvements. Currently, my blog features around 2300 articles and is running smoothly on Netlify's free hosting platform 🎉. If you're interested in giving it a try, take a look at my Vitepress repository clone. I've created a branch with a 'prepare' command in the package.json file to ensure compatibility for direct use in my projects. You can simply add the branch version directly to your package.json file for experimentation. However, please note that I don't plan to maintain this branch after the pull request is merged; it's intended for testing purposes only. If you find this enhancement helpful or if it suits your needs, please consider leaving a like on my open pull request (PR) here to expedite the merge process. Your support would be greatly appreciated, and it can contribute to having these improvements in the upcoming versions. |
Some updates: Since v2.0.0-rc.3, we have replaced vue-router's original routes with lightweight custom routes to get better performance. Some results from @Mister-Hope : Case A: 4m41s → 1m28s For the case provided here VuePress build time improved from 13min to 4min. To answer the original question - the differences between VuePress and Vitepress - in short, the bottleneck is vue-router. VuePress is a typical SPA project with vue-router. Imagine that if you build a project with thousands of pages, you would have to define all the routes - and it would be slow to build for sure. In contrast, VitePress totally drops vue-router, so that we don't need to define all the routes. Instead, VitePress implemented a super light weight router with the help of vite. Thus, for VuePress:
|
Description
Try to build with 1000 .md files
Vuepress takes more than 10min to compile and render, in both vite-bundler and webpack-bundler
Meanwhile, [email protected] only takes 30s
The core part of build-bundler - Vite is the same, so the problem may be how VuePress processes or organises
.md
and.vue
. What is the difference between VitePress and VuePress during compiling & rendering?Used Package Manager
npm
System Info
The text was updated successfully, but these errors were encountered: