Skip to content
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

Fix Zero Length Images #160

Merged
merged 10 commits into from
May 3, 2021

Conversation

deanmarcussen
Copy link
Collaborator

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Fixes #158

As discussed on the issue the ConcurrentDictionary arrangement introduced to replace the AsyncKeyLock was misbehaving, and not always writing a response, when under high load.

This pr rearranges the workers to always return an ImageWorkResult from which a response will be written.

It also replaces Lazy with what is recommended as a better way of controlling async ConcurrentDictionary GetOrAdds

Performance numbers drop unfortunately, but still remain better than the AsyncKeyLock
This pr : Reqs/sec 6943.78
Master : Reqs/sec 41455.71
AsyncKeyLock : Reqs/sec 2299.19 (master at aa1b192)

Note: Not rushing this, there's a couple of areas worth looking at a bit further, I will add some comments to the pr

@codecov
Copy link

codecov bot commented Apr 26, 2021

Codecov Report

Merging #160 (76a781f) into master (8f67aae) will decrease coverage by 0.49%.
The diff coverage is 88.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #160      +/-   ##
==========================================
- Coverage   84.82%   84.32%   -0.50%     
==========================================
  Files          46       48       +2     
  Lines        1364     1410      +46     
  Branches      177      187      +10     
==========================================
+ Hits         1157     1189      +32     
- Misses        159      166       +7     
- Partials       48       55       +7     
Flag Coverage Δ
unittests 84.32% <88.03%> (-0.50%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...p.Web/Middleware/ConcurrentDictionaryExtensions.cs 50.00% <50.00%> (ø)
.../ImageSharp.Web/Middleware/ImageSharpMiddleware.cs 85.92% <91.66%> (-1.96%) ⬇️
src/ImageSharp.Web/Middleware/ImageWorkerResult.cs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f67aae...76a781f. Read the comment docs.

@JimBobSquarePants
Copy link
Member

Performance numbers drop unfortunately, but still remain better than the AsyncKeyLock
This pr : Reqs/sec 6943.78
Master : Reqs/sec 41455.71
AsyncKeyLock : Reqs/sec 2299.19 (master at aa1b192)

Ooft that stings! Better a working slower solution but ow!

@deanmarcussen
Copy link
Collaborator Author

Ooft that stings! Better a working slower solution but ow!

I am gutted :(

@JimBobSquarePants
Copy link
Member

I'm gonna have a deeper look at the issue here. I'm wondering if there's a less drastic fix.

@deanmarcussen
Copy link
Collaborator Author

That would be great @JimBobSquarePants this needs as many eyes as possible.

I've had a final run through with this pr, and am happy with it.

@JimBobSquarePants JimBobSquarePants merged commit fa18357 into SixLabors:master May 3, 2021
@mariojsnunes
Copy link

Hi, when can we expect a release with this? The memory leak fix is really important :)

@JimBobSquarePants
Copy link
Member

I’m awaiting confirmation in the discussion here from a support license holder.

#161

@deanmarcussen
Copy link
Collaborator Author

@mariojsnunes the release is available on the myget feed https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.ImageSharp.Web/1.0.3-alpha.0.4

It would be great to get any feedback on it.

@mariojsnunes
Copy link

mariojsnunes commented May 10, 2021

Tested with OrchardCore on an Azure App Service.
It seems to be solved.
Memory graph increases but goes down right after (5min). Before it would stay up until a server restart.

  • First test requesting with 100 big images at the same time (~10mb) the memory increases a lot but returns to normal.
  • Second test with 250 small images (~250kb) memory changes are barely noticeable.
  • Requesting images after them being server-side cached has no impact on memory.

@JimBobSquarePants
Copy link
Member

Thanks for the feedback @mariojsnunes very useful!

I'll get a NuGet release issued ASAP. there's little point holding out.

@markmccaigue
Copy link

Hi folks, I've also just completed some testing of the latest packages from MyGet, and can confirm that they appear to have fixed the issue I raised in #158, magic!

@JimBobSquarePants
Copy link
Member

Ace, thanks for reporting back!

@JimBobSquarePants
Copy link
Member

New NuGet release available. https://www.nuget.org/packages/SixLabors.ImageSharp.Web/1.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Response body is sometimes empty when processing multiple identical queries
4 participants