-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Major CPU performance decrease with ImageSharp.Web 3 #344
Comments
Thanks for the detail. Have you been able to profile this? I’m wondering if this is related? It might be worth trying one of the nightly builds. Hard to determine the issue without profiling. |
I have not been able to profile the issue. I will try updating to the nightly Feedz.io build to see if that fixes the issue. We don't use the HMAC-protection. Is it enabled by default? If so, is there a way to disable it? |
I did try the nightly build. Based on your comment I compared the
Now I do have a license for all Jetbrains .NET tools, including the profiler build into Rider and the separate dotTrace Profiler application, however I don't have much experience with it. |
The Jetbrains Tools don't really provide the detailed information you need running under stress so instead I've benchmarked the solution using Crank It's fairly straightforward to get started.
Now... That all said I'm not seeing the issues you are, Application build and startup churns through the CPU a bit more for some reason but the load tests are equivalent. If anything v3 has a slightly higher max throughput. |
My 2 cents:
|
I just (yesterday) upgraded to the newly released 3.1 version, and the problematic CPU usage seems to be fixed. @adamsitnik good points.
|
I can happily report that our application has been running 3.1 for several days now and has had no CPU issues. |
Huzzah!! |
@JimBobSquarePants I seem to be running into the issue described in SixLabors/ImageSharp#2450. Do I need to configure the GIF Encoder with specific settings to use this, or may it be that I'm running into a different GIF issue? |
No special configuration required. Can you share the image, there’s an edge case I fixed 3 days ago but it should be fairly rare. |
It's the deduper. Your images use a global palette with 256 entries and no transparency. I'm introducing transparency but not replacing the palette. I just fixed it locally and will push out a v3.1.1 release with this and other fixes later once I PR it. Here's my version with the fix. As a bonus it's only 480KB vs 654KB original. |
Awesome! That is a size reduction of 26%! When the new version is out I will verify it locally against all our current banners. |
You can grab ImageSharp v3.1.1 now from NuGet. It's binary compatible with ImageSharp.Web v3.1.0 If your company hasn't purchased a license already and meet the criterea, please do so. It helps keep the lights on here. |
There’s no guarantees. When we load a gif we have to coalesce the frame deltas losing all previous optimisations. We do a ton of work to reintroduce optimisations but sometimes we can’t match original meticulous individual encodings. There are changes we could theoretically make to the deduping process to enable better compression but they’d make encoding times too slow. |
I get that. For the web use case I think it would be nice to have the option to use more aggressive compression. It's not even only about saving bandwidth costs, but also about faster load times for the end user, and saving them bandwidth. |
It’s very intense for gif since there’s no line filtering. You’d have to have multiple deduplication strategies that ignore diffs when there are not multiple in a row. Then you’d have to compress each whole image frame multiple times and compare. Ideally our current strategy saves overall so individual differences become less relevant. |
Aha. Excuse my ignorance about stuff like this. With awesome libraries like ImageSharp most developers rarely need to get into these kind of details. When looking into ways to save bandwidth I found out that both browsers and ImageSharp support WebP now. I will definitely investigate whether we can save bandwidth by using ImageSharp to convert our GIF images to WebP. |
Prerequisites
DEBUG
andRELEASE
modeImageSharp.Web version
3.0.1
Other Six Labors packages and versions
None
Environment (Operating system, version and so on)
Azure App Service Windows
.NET version
7
Description
After upgrading to ImageSharp.Web 3 we noticed a major increase of CPU usage.
We then proceeded with steps to isolate the issue so we would be 100% sure that the version increase was indeed the cause:
Technical background
NullImageCache
.NullImageCache
we used thePhysicalFileSystemCache
. It ended up breaking our App Service because we eventually ran out of disk space, because the cache does not remove old images (note: I now know that this is a non-trivial issue, I would propose making this more clear in the documentation).RemoteImageProvider
which usesHttpClient
to load images from an url.PresetOnlyQueryCollectionRequestParser
.Background
A few weeks back I found out that version 3 of ImageSharp.Web was released. I also found out that the license had been changed.
After arranging the purchase of the license I upgraded.
Based on the release notes I expected to see a performance improvement, but unfortunately it quickly became clear that we instead had a performance decrease.
I explicitly waited with reporting the issue until I was 100% sure that it is caused by the ImageSharp.Web upgrade.
I checked the changelogs of ImageSharp.Web and ImageSharp, but I could not find any change that which might cause our issue.
I am willing to help with identifying the cause of the issue, but I would like some pointers with regards to how to proceed.
Steps to Reproduce
At this point the "Steps to Reproduce" are not clear beyond "Upgrade from ImageSharp.Web 2.0.2 to 3.0.1".
However, I can share all the relevant code that we use.
This is the library that contains all our
ImageSharp.Web
code.PMP.ImageProcessing.zip
The
PMP.ImageProcessing
library is used in a minimal web application.PMP.ImageProcessor.zip
Images
The red arrow indicates the point where the version 2 of ImageSharp.Web was deployed.
The graph shows that with ImageSharp.Web 3 both average and maximum CPU usage are at least 2 times higher.
The text was updated successfully, but these errors were encountered: