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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ImageSharpMiddleware no-op case's performance #69

Merged
merged 3 commits into from
Aug 20, 2019

Conversation

lahma
Copy link
Contributor

@lahma lahma commented Aug 15, 2019

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

I profiled Orchard Core as @sebastienros gave the idea. I saw that ImageSharp was doing some unnecessary processing as part of the pipeline when the request ended to be no-op on ImageSharp's behalf. I tweaked following bits:

  • reduce usage of LINQ, which is always more expensive than "code nearer to the metal"
  • change error handling to be more easy to inline (micro optimization)
  • use concrete types as fields, no extra penalty from interface access
  • split the actual work to ProcessRequest when actually needed
  • don't parse in OnParseCommands when result is discarded

@CLAassistant
Copy link

CLAassistant commented Aug 15, 2019

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really good! Just a few minor changes required and I'll be very happy to merge this in. Thanks! 馃憤

src/ImageSharp.Web/Guard.cs Outdated Show resolved Hide resolved
src/ImageSharp.Web/Middleware/ImageSharpMiddleware.cs Outdated Show resolved Hide resolved
@lahma
Copy link
Contributor Author

lahma commented Aug 20, 2019

Thank you for the review, good points! I hope I got the fixes right and PR should be good now.

@JimBobSquarePants
Copy link
Member

Perfect! I'll merge this now, thanks for your help!

@JimBobSquarePants JimBobSquarePants merged commit b02a6f7 into SixLabors:master Aug 20, 2019
@lahma lahma deleted the perf/improve-middleware branch August 20, 2019 15:08
@lahma
Copy link
Contributor Author

lahma commented Aug 20, 2019

You're most welcome, thanks for accepting the PR!

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

Successfully merging this pull request may close these issues.

None yet

3 participants