Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
perf: remove zopfli to speed up webpack #10288
This PR removes zopfli compression, speeding up webpack compilation in production by ~7.5x (6m36s -> 0m53s).
I did some profiling of the command:
RAILS_ENV=production bundle exec rails assets:precompile
after some digging, I found I could debug webpack using:
RAILS_ENV=production NODE_ENV=production node --inspect-brk /home/nolan/workspace/mastodon/node_modules/.bin/webpack --config /home/nolan/workspace/mastodon/config/webpack/production.js
So I took a trace. I think the screenshot speaks for itself:
My benchmark is the following:
rm -fr tmp/ RAILS_ENV=production bundle exec rails assets:precompile
Then I use the
Without the fix, this takes 6m36.437s in real time on my Dell XPS 13. With the fix, it takes 0m52.958s (~7.5x improvement).
Zopfli outputs a very compact gzip format, but it's slow. Removing it speeds things up considerably.
Even though nginx's default gzip output may be less efficient than zopfli, I don't think it's reasonable to force every instance admin to run this command which takes a very long time. Maybe some admins aren't even using gzip – maybe they're using Brotli. They can also configure the gzip options in nginx, or run zopfli themselves.
As a future improvement, I don't think generating