-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Image processing parallelity #12845
Comments
It already uses a concurrency based on the CPU count. There may be other factors preventing full CPU utilisation. The most likely is probably disk IO, but as image generation is part of the build pipeline there are lots of other factors that might be affecting it. If you feel like digging in, there isn't any specific logging there about CPU utilisation, but you can have a look in the part of the code that I linked and maybe add debug logs to see if it's fully using your cores, and expeirment with manually setting different values and see if it improves performance. Node CPU counts can be unreliable, particularly when running in containerised environments, so it may be worth adding support for manually setting concurrency. If you decide to look into this I'd be interested in seeing your results, but for now I'm closing this as it's not really a bug. |
@ascorbic thanks for the insight. I’ve been wrestling with this and discovered the underlying issue. Just below your reference in core/build/generate.ts, there is an for (const [originalPath, transforms] of staticImageList) {
await generateImagesForPath(originalPath, transforms, assetsCreationPipeline, queue);
} Inside the loop In my test of roughly 2,000 image transforms, removing the I would recommend removing the for (const [originalPath, transforms] of staticImageList) {
generateImagesForPath(originalPath, transforms, assetsCreationPipeline, queue);
} Additionally, there is another I think adding a configurable concurrency in astro.config.ts would be a nice-to-have. Something similar to the experimental |
Well spotted! Removing that should be fine, because we await the idle queue below it. A PR to just remove that await would be a good start. The others would need more thought. |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
Build issue
Describe the Bug
Performance of image processing could be improved by making it more parallel. I am having a 16 core CPU and the CPU utilization is 25-40%. By the numbers of images I added, I would have expected better utilization of the CPU by processing more pictures in parallel
What's the expected result?
More load on the CPU when optimizing images by using all cores
Link to Minimal Reproducible Example
Participation
The text was updated successfully, but these errors were encountered: