-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Very slow formatMessages
#3467
Comments
I'm not exactly sure where the quadratic aspect is coming from other than perhaps increasing GC pressure since each individual message formatting operation should be independent. In any case, it looks like this case is formatting an extremely long line with an error toward the beginning. There is some code that scans the whole string but it's not technically necessary to scan the whole string in this specific case. The scans could potentially also be rewritten to use SIMD-optimized code paths to make this even faster. |
Actually now that I'm looking at this again, I think most of the time is going into esbuild's cross-process serialization from a JavaScript string into Go bytes. String manipulation in JavaScript combined with node's pipe serialization is unfortunately slow for large amounts of data. I'll do what I can for this. Edit: Here's a quick before/after result:
Most of the time was saved by just deleting most of the input at the start of |
I have a big-ish react app build with
vite
. After upgrading one of my dependencies the build time on netlify skyrocketed from 30 seconds to over 15 minutes. The build was fast again after I turned off CSS minification.While building esbuild would use 100% CPU for a long time, so I digged and it turned out it's not the minification that is slow, but
formatMessages
thatvite
calls later. Because of a problem in some CSS-in-JS transitive dependency, I ended up with 1.5 MB minified CSS files with mulitple empty:is()
selectors, for which esbuild issued 360 warnings. The analogue of the warnings array below had 388MB.The following minimal example shows the issue. While
vite
usesesbuild
0.18, this issue persists in the latest 0.19.5.Running times suggest a quadratic algorithm somewhere:
The text was updated successfully, but these errors were encountered: