-
-
Notifications
You must be signed in to change notification settings - Fork 862
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
Tiff: Performance improvements for Fax4 decompression #2134
Conversation
@brianpopow - I noticed that there seem to be a number of "constant" dictionaries that are used. I've seen many situations where dictionaries like that are refactored into a static switch method. This provides better performance because the C# compiler will optimize each switch statement instead of relying on the General purpose Dictionary Class. Wanted to mention that because it may further reduce memory as well. |
Err, further reduce execution time. |
…from the stream to avoid allocation
So far we are down from 117,745.8 us to 15,028.70 us. edit: with 10ff24f we are down to 12,071.3 us |
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbaFloat32323232TiffColor{TPixel}.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Berkan Diler <b.diler@gmx.de>
I'll take a closer look and play with benchmarks when this is shipped but I don't understand atm why bits are pushed bit by bit when we can have a lookup table or maybe a somehow optimized byte value generation. |
Thanks @br3aker, it would be good to have another pair of eyes looking at this, since I am not sure how or if this can be improved further. I will mark it now as Ready for review. Nevertheless I think the improvement compared to edit: btw: huffman and fax3 decompression also benefit from this PR. |
90% speedup is simply incredible :) I believe we can win a lot in those bit insertions though. |
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor{TPixel}.cs
Show resolved
Hide resolved
- Deflate and packbits are not supported by System.Drawing - When 1d Compression is chosen, TiffPhotometricInterpretation should be WhiteIsZero
@brianpopow Thank you so much for your work on this. Do you have the ability to publish an updated nuget package? If so, can you make that happen? |
@TonyValenti only new stable release versions and hotfix versions will be published via Nuget, but you can use our MyGet feed for alpha releases: https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.ImageSharp Just add this as an additional package source and you are good to go. |
Prerequisites
Description
This PR brings performance improvements for Tiff Fax4 decompression.
Related to #2132
Benchmarks:
main
PR
note:
Tiff/CCITTGroup4.tiff
is the image from #2132