Skip to content
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

[performance] Compress in parallel #54

Closed
jaymakes11 opened this issue Nov 17, 2022 · 9 comments
Closed

[performance] Compress in parallel #54

jaymakes11 opened this issue Nov 17, 2022 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@jaymakes11
Copy link

Love this package!

But not the performance, especially when using it with lots of image files :(

It doesn't seem to be compressing in parallel.

A "make parallel" improvement to Astro's build command was made here. Perhaps something similar could be done here to improve the performance.

From a quick look at the code, perhaps the current bottleneck somewhere here?

Happy to take a stab at making some improvements on this once I can free-up some time.

@jaymakes11
Copy link
Author

jaymakes11 commented Nov 17, 2022

For context, I'm seeing astro-compress take around 30 minutes to compress ~1,000 images (on an M1 Max).

1,000 images might seem like a lot, but current responsive/retina best practices result in lots of image variants (the site in reference here only has 36 source images).

@NikolaRHristov
Copy link
Member

NikolaRHristov commented Nov 17, 2022

Thank you, I've been wondering about how to make it compress in parallel!

@NikolaRHristov NikolaRHristov added the enhancement New feature or request label Nov 17, 2022
@NikolaRHristov
Copy link
Member

Expect it in 1.2.0

@NikolaRHristov
Copy link
Member

So I did a benchmark with three different methods https://github.com/nikolaxhristov/bench-piscina I think piscina might be the best for this.

@johnzanussi
Copy link
Contributor

@nikolaxhristov I would love to help out with this if it's something you want help with.

@NikolaRHristov
Copy link
Member

NikolaRHristov commented Feb 9, 2023

@johnzanussi TY! ❤️ I would love some help. I wanted to make the files-pipe component itself parallelized, so whatever you use in callbacks gets called parallelly. This is used by astro-compress, astro-rome, astro-critters and a few other extensions, so it would greatly benefit the whole ecosystem.

Ideally, this would be parallelized https://github.com/lightrix/files-pipe/blob/main/src/lib/files/pipe.ts

Of all my benchmarks I stopped at piscina https://github.com/nikolaxhristov/bench-piscina, but if you have other suggestions, I'm open.

I have a repo that's a bit unmaintained at the moment to test those exact extensions https://github.com/nikolaxhristov/bench and the files-pipe component itself.

@kyeshmz
Copy link

kyeshmz commented Dec 1, 2023

Is there a way to cache previously compressed files? It would help out rather than making things parallel, as I think that is much harder

@NikolaRHristov
Copy link
Member

@kyeshmz See: #49

@azat-io
Copy link

azat-io commented May 4, 2024

It would be nice to be able to run the compressor in parallel. I have a lot of images in my project too and the application build currently takes 26 minutes

@NikolaRHristov NikolaRHristov closed this as not planned Won't fix, can't repro, duplicate, stale May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

5 participants