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

Remove exists check for blobs #10960

Merged

Conversation

ShaneCourtrille
Copy link
Contributor

@ShaneCourtrille ShaneCourtrille commented Jan 4, 2022

Fixes #10876 I have found a good performance improvement in the BlobFileStore by replacing the ExistsAsync call with a handler for the exception which occurs if the blob doesn't exist.

Switch BlobFileStore.GetFileInfoAsync to handle blob not found exceptions as opposed to doing an explicit ExistsAsync() check.  This call is quite expensive when considering that callers to GetFileInfoAsync are normally going to find the blob due to the app being very read heavy.
var properties = await blob.GetPropertiesAsync();

return new BlobFile(path, properties.Value.ContentLength, properties.Value.LastModified);
}
catch (RequestFailedException ex) when (ex.ErrorCode == "BlobNotFound") // Instead of ExistsAsync() check which is 'slow' if we're expecting to find the blob
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, tested it out and using the BlobErrorCode works.

@sebastienros sebastienros enabled auto-merge (squash) January 10, 2022 17:53
@sebastienros sebastienros merged commit 7331f95 into OrchardCMS:main Jan 10, 2022
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.

BlobFileStore performance improvement
2 participants