-
Notifications
You must be signed in to change notification settings - Fork 6
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
dev: set some next settings to improve build times #998
Conversation
@@ -52,6 +52,8 @@ const nextConfig = { | |||
], | |||
experimental: { | |||
optimizePackageImports: ["@icons-pack/react-simple-icons", "lucide-react"], | |||
webpackBuildWorker: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be specifically enabled for parallelServerBuildTraces
to work
if (config.cache && !dev) { | ||
config.cache = Object.freeze({ | ||
type: "memory", | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as mentioned in the pr, we could theoretically add && env.CI
here to only have this happen on CI, but i prefer shorter initial build times locally as well
Wow, just tested locally. Prior to your changes: pnpm --filter=core build 133.87s user 20.98s system 215% cpu 1:11.99 total After your changes: pnpm --filter=core build 81.73s user 11.75s system 190% cpu 49.179 total So yeah, about a 50 second improvement. Super nice! |
Issue(s) Resolved
Next builds are long.
High-level Explanation of PR
TLDR: total CI time decrease for building core is 1m30s!! very nice
Enables
experimental.parallelServerBulldTraces
innext.config.mjs
. This makes the tracing of server routes take place in a separate worker, which slightly decreases build times (ideally).As you can see below, this results in ~50s or roughly 19% faster
next build
s! Seems great for doing literally nothing.Additionally, I disable webpack caching in line with this next recommendation. Currently serializing and writing the webpack cache takes a long time, we even get this warning often
Disabling this cache writing results in an additional 40s saved.
In total, this results in a 33% decrease in
next build
times!!This is imo still crazy slow, but at least it's slightly less so.
Note
The webpack cache is very useful, in theory. If we could effectively cache it, subsequent builds would be substantially faster.
I've not been able to figure out how to do this in docker yet though (caching docker layers is prohibitively slow, we should not do it).
We could only disable the webpack cache on CI, but i'm personally very rarely doing repeated builds myself without doing a
next dev
in between, so i'd rather have a faster initial build locally than faster rebuilds.In CI
Time is last step of
#24
the stepBuild, Tag, and Push to ECR
Main
https://github.com/pubpub/platform/actions/runs/13527437906/job/37801720865
https://github.com/pubpub/platform/actions/runs/13541214032/job/37842525354?pr=998
+
webpackBuildWorker
+parallelServerBuildTraces
https://github.com/pubpub/platform/actions/runs/13542305151/job/37845940104?pr=998
+
webpackBuildWorker
+parallelServerBuildTraces
+ cache freezeImprovement of 50ish seconds, not bad!
On my machine
result of running
Main
+
webpackBuildWorker
+
webpackBuildWorker
+parallelServerBuildTraces
So a 30ish to 60ish second decrease, pretty nice!
+
webpackBuildWorker
+parallelServerBuildTraces
+ cache freezeAn additional 50sec decrease! very nice
Test Plan
Run build locally, hopefully do not get OOM errors.
Check that Sentry sourcemaps are still being uploaded correctly (should not be influenced i think)
Screenshots (if applicable)
Notes