Skip to content

Loading TIFFs is 50x Slower #2132

Description

@TonyValenti

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

ImageSharp version

2.1.2

Other ImageSharp packages and versions

???

Environment (Operating system, version and so on)

Windows 11 x64

.NET Framework version

6.0.5

Description

Hi ImageSharp,
Run this code with the attached image and you'll see that loading TIFFs is 50x slower than SDI.
Can you please take a look? Happy to buy a license / sponsorship if we can get this resolved sooner rather than later.

Steps to Reproduce

        var Input = $@"C:\Users\TonyV\Downloads\Image1.tiff";
        
        var SW1 = System.Diagnostics.Stopwatch.StartNew();
        for (int i = 0; i < 100; i++) {
            System.Drawing.Image.FromFile(Input);
        }
        Console.WriteLine($@"SW1 {SW1.Elapsed}");


        var SW2 = System.Diagnostics.Stopwatch.StartNew();
        for (int i = 0; i < 100; i++) {
            SixLabors.ImageSharp.Image.Load(Input);
        }
        Console.WriteLine($@"SW2 {SW2.Elapsed}");

Images

Image1.zip

Activity

  1. brianpopow commented on May 28, 2022

    @brianpopow
    Collaborator

    @TonyValenti If you buy a license, I could take a look into this. I have some idea's why this might be slow.

    edit: disclaimer: I am pretty sure we can make it faster, but I cannot promise a speedup of 50.

  2. TonyValenti commented on May 28, 2022

    @TonyValenti
    Author

    @brianpopow Done! I'd be surprised if you got a 50x speedup as well, but I'd be quite happy with 49x. :-)

  3. br3aker commented on May 28, 2022

    @br3aker
    Contributor

    Won't be surprised if SDI uses the same 'optimization' technique as in jpeg decoder-encoder with caching the initial file if image wasn't changed. I'll actually test it right now.

    UPD:
    Didn't read it's only a load operation...

  4. brianpopow commented on May 28, 2022

    @brianpopow
    Collaborator

    @TonyValenti Is it ok for you, if we use the image you have provided in our benchmarks?

  5. TonyValenti commented on May 28, 2022

    @TonyValenti
    Author

    Yep!

  6. TonyValenti commented on May 29, 2022

    @TonyValenti
    Author

    Also, I'm sure you've noticed, but it seems like memory usage explodes too.

  7. JimBobSquarePants commented on May 29, 2022

    @JimBobSquarePants
    Member

    Let’s do some proper benchmarking. Those tests above will be wildly inaccurate. The code sample leaks memory also

  8. brianpopow commented on Jun 9, 2022

    @brianpopow
    Collaborator

    With #2134 merged to main, the image linked here should decode much faster. The image uses Fax4 compression, but all fax de-compression should be faster now.

    You can try it out with our latest nightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions