-
Notifications
You must be signed in to change notification settings - Fork 232
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
Artifacts when using multi-threaded option #60
Comments
Alright, I think I found the issue in the first example: |
I believe #62 should fix the first example. |
Note that the second issue definitely seems caused by the threaded code since the image looks fine without the |
Hi there,
I believe this is not thread-safe. |
I made a couple experimental branches to try to dig into this colormap thing. Colormap thread-safe access + rebuilding Global to local colormap: Here's an example image: No threading ( With threading and mutexes + With threading and global-to-local colormap copy ( edit: here's how it looks with the current code using |
@thierrylamarre what is the performance cost of using the mtuxes + kd3_tree rebuilding? From visual inspection of the above, it definitely looks very close (or identical?) to the non-threaded resize, and there is no flickering as you mention. |
@wilkesybear performance, in terms of the time it takes to resize an image regardless of cpu usage which is what the multi-threading is meant to improve, is almost the same as using single-threaded 😞. What's killing it is adding these rather large critical sections, making it near-single-threaded in practice. |
I'm not sure this problem is as big as you imply. Every thread has its own global kd3_tree. There certainly is a multithreading problem with access to the global colormap in |
Please see 2e136b4, which is like your threaded_colormap_experiment but with much smaller critical sections: Only the actual accesses to the global colormap are protected with a mutex. Since each thread has its own Your GIF resized with this commit: (I'm still not sure whether I think threaded resize is a good idea overall. Multithreading is hard, the required unoptimization step is expensive, there might still be bugs, etc., etc.) But thanks for finding the issue! Let me know if this commit does or doesn't work for you. |
Thanks a lot! I can't blame you if you decide not to support multi-threading going forward. It's very useful to us but it's a very niche use-case and I understand you may not want to continue having to maintain it. Thanks again! |
Thank you for finding the issue and your debugging work! |
Hello,
there appears to be a bug when resizing gifs using the multi-threaded option (-j).
Here is an example original image:
And the result where you can see some lines/a square around the moving eyebrow:
The following command was used:
gifsicle -i input.gif -j8 --resize-method catrom --resize-colors 64 -O2 --resize-fit "250x400" -o output.gif
Another example is this image:
which then looks like this:
This second image was resized using also the
-U
option. It is too complex to resize in a multi-threaded fashion without unoptimizing first:gifsicle -U -i input.gif -j8 --resize-method catrom --resize-colors 64 -O2 --resize-fit "250x400" -o output.gif
@wilkesybear
The text was updated successfully, but these errors were encountered: