diff --git a/.gitignore b/.gitignore index d44178396a..5776519d88 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,6 @@ website/i18n/**/* website/rspack-tracing.json website/bundler-cpu-profile.json +website/profile.json.gz + + diff --git a/package.json b/package.json index e48928ab6b..0e9d63abf9 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,9 @@ "build:website:deployPreview": "yarn build:website:deployPreview:testWrap && yarn build:website:deployPreview:build", "build:website:fast": "yarn workspace website build:fast", "build:website:fast:rsdoctor": "yarn workspace website build:fast:rsdoctor", - "build:website:fast:profile": "yarn workspace website build:fast:profile", "build:website:en": "yarn workspace website build --locale en", + "profile:bundle:cpu": "yarn workspace website profile:bundle:cpu:profile", + "profile:bundle:samply": "yarn workspace website profile:bundle:samply", "clear:website": "yarn workspace website clear", "serve:website": "yarn workspace website serve", "serve:website:baseUrl": "serve website", diff --git a/packages/docusaurus-utils/src/lastUpdateUtils.ts b/packages/docusaurus-utils/src/lastUpdateUtils.ts index a11dc782ef..5b024d0067 100644 --- a/packages/docusaurus-utils/src/lastUpdateUtils.ts +++ b/packages/docusaurus-utils/src/lastUpdateUtils.ts @@ -71,7 +71,10 @@ export const LAST_UPDATE_FALLBACK: LastUpdateData = { export async function getLastUpdate( filePath: string, ): Promise { - if (process.env.NODE_ENV !== 'production') { + if ( + process.env.NODE_ENV !== 'production' || + process.env.DOCUSAURUS_DISABLE_LAST_UPDATE === 'true' + ) { // Use fake data in dev/test for faster development. return LAST_UPDATE_FALLBACK; } diff --git a/packages/docusaurus/src/webpack/base.ts b/packages/docusaurus/src/webpack/base.ts index ab20bbc51e..c05e022fcf 100644 --- a/packages/docusaurus/src/webpack/base.ts +++ b/packages/docusaurus/src/webpack/base.ts @@ -187,6 +187,10 @@ export async function createBaseConfig({ // @ts-expect-error: Rspack-only, not available in Webpack typedefs incremental: !isProd && !process.env.DISABLE_RSPACK_INCREMENTAL, + // TODO re-enable later, there's an Rspack performance issue + // see https://github.com/facebook/docusaurus/pull/11178 + parallelCodeSplitting: false, + ...PersistentCacheAttributes, }; } @@ -249,14 +253,14 @@ export async function createBaseConfig({ modules: ['node_modules', path.join(siteDir, 'node_modules')], }, optimization: { - // The optimizations.concatenateModules is expensive + // The optimization.concatenateModules is expensive // - On the server, it's not useful to run it at all // - On the client, it leads to a ~3% JS assets total size decrease // Let's keep it by default, but large sites may prefer faster builds // See also https://github.com/facebook/docusaurus/pull/11176 concatenateModules: !isServer, - // The optimizations.mergeDuplicateChunks is expensive + // The optimization.mergeDuplicateChunks is expensive // - On the server, it's not useful to run it at all // - On the client, we compared assets/js before/after and see 0 change // `du -sk js-before js-after` => the JS assets have the exact same size diff --git a/project-words.txt b/project-words.txt index 2151d48837..d048138934 100644 --- a/project-words.txt +++ b/project-words.txt @@ -266,6 +266,8 @@ Rspack rspack Rspress rtcts +Samply +samply saurus Scaleway Sebastien diff --git a/website/package.json b/website/package.json index 92cfcecfc5..b496d2d960 100644 --- a/website/package.json +++ b/website/package.json @@ -23,7 +23,8 @@ "build:blogOnly": "cross-env yarn build --config=docusaurus.config-blog-only.js", "build:fast": "cross-env BUILD_FAST=true yarn build --locale en", "build:fast:rsdoctor": "cross-env BUILD_FAST=true RSDOCTOR=true yarn build --locale en", - "build:fast:profile": "cross-env BUILD_FAST=true node --cpu-prof --cpu-prof-dir .cpu-prof ./node_modules/.bin/docusaurus build --locale en", + "profile:bundle:cpu": "DOCUSAURUS_EXIT_AFTER_BUNDLING=true node --cpu-prof --cpu-prof-dir .cpu-prof ./node_modules/.bin/docusaurus build --locale en", + "profile:bundle:samply": "./profileSamply.sh", "netlify:build:production": "yarn docusaurus write-translations && yarn netlify:crowdin:delay && yarn netlify:crowdin:uploadSources && yarn netlify:crowdin:downloadTranslations && yarn build", "netlify:build:branchDeploy": "yarn build", "netlify:build:deployPreview": "yarn build", diff --git a/website/profileSamply.sh b/website/profileSamply.sh new file mode 100755 index 0000000000..c0bb90fe07 --- /dev/null +++ b/website/profileSamply.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + + +echo "This Samply profiling script doesn't work when it's run with Yarn, but you can run it manually instead" + +samply record -- DOCUSAURUS_EXIT_AFTER_BUNDLING=true node --perf-prof --perf-basic-prof --interpreted-frames-native-stack ./node_modules/.bin/docusaurus build --locale en