FileOnQ / Imaging.Heif

A C#/.NET wrapper around libheif for decoding and processing high efficiency image formats (heif, heic).
GNU Lesser General Public License v3.0
15 stars 4 forks source link

Compile libjpeg-turbo As Debug or Release #42

Closed SkyeHoefling closed 2 years ago

SkyeHoefling commented 2 years ago

Fixes: #2 Fixes: #37

Description

libjpeg-turbo now compiles under the designated build configuration Debug or Release mode. When compiling the final binary for NuGet it will use the release build. This fixes issues downstream on client facing apps where libjpeg-turbo was dependent on debug binary vcruntime140d.dll

Merge Checklist

SkyeHoefling commented 2 years ago

@kenny-sellers can you download the generated NuGet package and load it into the console app. Then follow these steps to validate the fix

Console App Test

  1. Create a clean Windows 10 VM
  2. Download the latest Visual C++ Redistributable Packages from Microsoft for both x86 and x64 - then install them
  3. Run the sample and validate everything works

WinForms App Test

Perform the same test above but with the WinForms app from #44. I will review that today and merge then rebase so it is available in this PR

If you can complete the tests above, you can approve this PR

SkyeHoefling commented 2 years ago

/benchmark

SkyeHoefling commented 2 years ago

/benchmark

SkyeHoefling commented 2 years ago

Benchmarks are failing because of #45 it doesn't support forked repositories

SkyeHoefling commented 2 years ago

/benchmark

github-actions[bot] commented 2 years ago

Benchmark Comparison

Benchmarking comparison between this Pull Request and the comitted values at benchmarks/results

thumbnail


Welcome to .NET 5.0!
---------------------
SDK Version: 5.0.404

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
No differences found between the benchmark results with threshold 10%.

primary

 summary:
better: 4, geomean: 1.155
total diff: 4

No Slower results for the provided threshold = 10% and noise filter = 0.3ns.

| Faster                                                             | base/diff | Base Median (ns) | Diff Median (ns) | Modality|
| ------------------------------------------------------------------ | ---------:| ----------------:| ----------------:| --------:|
| FileOnQ.Imaging.Heif.Benchmarks.PrimaryImage.PrimaryImage_ToArray  |      1.20 |    2880173350.00 |    2396931900.00 |         |
| FileOnQ.Imaging.Heif.Benchmarks.PrimaryImage.PrimaryImage_ToSpan   |      1.15 |    2770930800.00 |    2401961600.00 |         |
| FileOnQ.Imaging.Heif.Benchmarks.PrimaryImage.PrimaryImage_Write    |      1.14 |    2724795550.00 |    2394350400.00 |         |
| FileOnQ.Imaging.Heif.Benchmarks.PrimaryImage.PrimaryImage_ToStream |      1.13 |    2719733500.00 |    2410643000.00 |         |

No file given

Benchmark Results

thumbnail

``` ini BenchmarkDotNet=v0.13.0, OS=Windows 10.0.17763.2366 (1809/October2018Update/Redstone5) Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 2 logical and 2 physical cores .NET SDK=5.0.404 [Host] : .NET 5.0.13 (5.0.1321.56516), X64 RyuJIT Job-DCQWTX : .NET 5.0.13 (5.0.1321.56516), X64 RyuJIT Runtime=.NET 5.0 InvocationCount=1 LaunchCount=1 UnrollFactor=1 ``` | Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | Allocated native memory | Native memory leak | |------------------- |---------:|---------:|---------:|------:|------:|------:|----------:|------------------------:|-------------------:| | Thumbnail_Write | 49.70 ms | 0.111 ms | 0.099 ms | - | - | - | 288 B | 5,124,409 B | - | | Thumbnail_ToArray | 49.84 ms | 0.165 ms | 0.147 ms | - | - | - | 66,408 B | 5,123,853 B | - | | Thumbnail_ToSpan | 49.66 ms | 0.152 ms | 0.127 ms | - | - | - | 120 B | 5,123,853 B | - | | Thumbnail_ToStream | 49.80 ms | 0.278 ms | 0.246 ms | - | - | - | 66,472 B | 5,123,597 B | - |

primary

``` ini BenchmarkDotNet=v0.13.0, OS=Windows 10.0.17763.2366 (1809/October2018Update/Redstone5) Intel Xeon Platinum 8272CL CPU 2.60GHz, 1 CPU, 2 logical and 2 physical cores .NET SDK=5.0.404 [Host] : .NET 5.0.13 (5.0.1321.56516), X64 RyuJIT Job-LPZDVK : .NET 5.0.13 (5.0.1321.56516), X64 RyuJIT Runtime=.NET 5.0 InvocationCount=1 LaunchCount=1 UnrollFactor=1 ``` | Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | Allocated native memory | Native memory leak | |---------------------- |--------:|---------:|---------:|------:|------:|------:|------------:|------------------------:|-------------------:| | PrimaryImage_Write | 2.393 s | 0.0061 s | 0.0048 s | - | - | - | 256 B | 222,029,348 B | - | | PrimaryImage_ToArray | 2.397 s | 0.0096 s | 0.0075 s | - | - | - | 1,943,008 B | 222,028,968 B | - | | PrimaryImage_ToSpan | 2.401 s | 0.0086 s | 0.0081 s | - | - | - | 88 B | 222,028,616 B | - | | PrimaryImage_ToStream | 2.411 s | 0.0086 s | 0.0081 s | - | - | - | 1,943,072 B | 222,028,680 B | - |

SkyeHoefling commented 2 years ago

@mitchelsellers comparing the primary conversion results, we are seeing about a 300ms to 400ms performance improvement here is what we have saved in the benchmark folder for reference


BenchmarkDotNet=v0.13.0, OS=Windows 10.0.17763.2114 (1809/October2018Update/Redstone5)
Intel Xeon CPU E5-2673 v4 2.30GHz, 1 CPU, 2 logical and 2 physical cores
.NET SDK=5.0.400
  [Host]     : .NET 5.0.9 (5.0.921.35908), X64 RyuJIT
  Job-UAQZJA : .NET 5.0.9 (5.0.921.35908), X64 RyuJIT

Runtime=.NET 5.0  InvocationCount=1  LaunchCount=1  
UnrollFactor=1  
Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated Allocated native memory Native memory leak
PrimaryImage_Write 2.736 s 0.0409 s 0.0341 s - - - 256 B 222,029,948 B -
PrimaryImage_ToArray 2.896 s 0.0486 s 0.0596 s - - - 1,943,008 B 222,029,376 B -
PrimaryImage_ToSpan 2.775 s 0.0372 s 0.0310 s - - - 88 B 222,029,424 B -
PrimaryImage_ToStream 2.738 s 0.0416 s 0.0389 s - - - 1,943,072 B 222,029,552 B -

I would like to run another benchmark since github runner environments isn't consistent, it appears the servers are different.

SkyeHoefling commented 2 years ago

/benchmark

github-actions[bot] commented 2 years ago

Benchmark Comparison

Benchmarking comparison between this Pull Request and the comitted values at benchmarks/results

thumbnail


Welcome to .NET 5.0!
---------------------
SDK Version: 5.0.404

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
No differences found between the benchmark results with threshold 10%.

primary

 summary:
better: 4, geomean: 1.154
total diff: 4

No Slower results for the provided threshold = 10% and noise filter = 0.3ns.

| Faster                                                             | base/diff | Base Median (ns) | Diff Median (ns) | Modality|
| ------------------------------------------------------------------ | ---------:| ----------------:| ----------------:| --------:|
| FileOnQ.Imaging.Heif.Benchmarks.PrimaryImage.PrimaryImage_ToArray  |      1.20 |    2880173350.00 |    2405408100.00 |         |
| FileOnQ.Imaging.Heif.Benchmarks.PrimaryImage.PrimaryImage_ToSpan   |      1.15 |    2770930800.00 |    2403818300.00 |         |
| FileOnQ.Imaging.Heif.Benchmarks.PrimaryImage.PrimaryImage_Write    |      1.14 |    2724795550.00 |    2399345100.00 |         |
| FileOnQ.Imaging.Heif.Benchmarks.PrimaryImage.PrimaryImage_ToStream |      1.13 |    2719733500.00 |    2401410000.00 |         |

No file given

Benchmark Results

thumbnail

``` ini BenchmarkDotNet=v0.13.0, OS=Windows 10.0.17763.2366 (1809/October2018Update/Redstone5) Intel Xeon Platinum 8272CL CPU 2.60GHz, 1 CPU, 2 logical and 2 physical cores .NET SDK=5.0.404 [Host] : .NET 5.0.13 (5.0.1321.56516), X64 RyuJIT Job-UXTCFB : .NET 5.0.13 (5.0.1321.56516), X64 RyuJIT Runtime=.NET 5.0 InvocationCount=1 LaunchCount=1 UnrollFactor=1 ``` | Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | Allocated native memory | Native memory leak | |------------------- |---------:|---------:|---------:|------:|------:|------:|----------:|------------------------:|-------------------:| | Thumbnail_Write | 47.95 ms | 0.435 ms | 0.407 ms | - | - | - | 288 B | 5,124,441 B | 32 B | | Thumbnail_ToArray | 47.70 ms | 0.438 ms | 0.410 ms | - | - | - | 66,408 B | 5,123,853 B | - | | Thumbnail_ToSpan | 47.59 ms | 0.417 ms | 0.390 ms | - | - | - | 120 B | 5,123,853 B | - | | Thumbnail_ToStream | 47.36 ms | 0.441 ms | 0.412 ms | - | - | - | 66,472 B | 5,123,901 B | 32 B |

primary

``` ini BenchmarkDotNet=v0.13.0, OS=Windows 10.0.17763.2366 (1809/October2018Update/Redstone5) Intel Xeon Platinum 8272CL CPU 2.60GHz, 1 CPU, 2 logical and 2 physical cores .NET SDK=5.0.404 [Host] : .NET 5.0.13 (5.0.1321.56516), X64 RyuJIT Job-YGAXZN : .NET 5.0.13 (5.0.1321.56516), X64 RyuJIT Runtime=.NET 5.0 InvocationCount=1 LaunchCount=1 UnrollFactor=1 ``` | Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | Allocated native memory | Native memory leak | |---------------------- |--------:|---------:|---------:|------:|------:|------:|------------:|------------------------:|-------------------:| | PrimaryImage_Write | 2.400 s | 0.0037 s | 0.0034 s | - | - | - | 256 B | 222,029,268 B | - | | PrimaryImage_ToArray | 2.406 s | 0.0049 s | 0.0045 s | - | - | - | 1,943,056 B | 222,028,584 B | - | | PrimaryImage_ToSpan | 2.402 s | 0.0061 s | 0.0054 s | - | - | - | 88 B | 222,028,360 B | - | | PrimaryImage_ToStream | 2.402 s | 0.0053 s | 0.0049 s | - | - | - | 1,943,072 B | 222,028,536 B | - |

SkyeHoefling commented 2 years ago

I compared the results to the values from #44 which is running on the same hardware as the original benchmark. It does appear to be faster


BenchmarkDotNet=v0.13.0, OS=Windows 10.0.17763.2366 (1809/October2018Update/Redstone5)
Intel Xeon Platinum 8272CL CPU 2.60GHz, 1 CPU, 2 logical and 2 physical cores
.NET SDK=5.0.404
  [Host]     : .NET 5.0.13 (5.0.1321.56516), X64 RyuJIT
  Job-TQEXEA : .NET 5.0.13 (5.0.1321.56516), X64 RyuJIT

Runtime=.NET 5.0  InvocationCount=1  LaunchCount=1  
UnrollFactor=1  
Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated Allocated native memory Native memory leak
PrimaryImage_Write 2.438 s 0.0480 s 0.0624 s - - - 256 B 222,030,124 B -
PrimaryImage_ToArray 2.379 s 0.0475 s 0.1072 s - - - 1,943,008 B 222,029,232 B -
PrimaryImage_ToSpan 2.493 s 0.0498 s 0.0731 s - - - 88 B 222,029,232 B -
PrimaryImage_ToStream 2.413 s 0.0479 s 0.1061 s - - - 1,943,072 B 222,029,248 B -