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

[Storage] Replace format with concat in Shared Key signature #24551

Merged
merged 1 commit into from
Oct 5, 2021

Conversation

kasobol-msft
Copy link
Contributor

resolves #24535 .

I used the following benchmark to validate improvement:

    public static void main(String[] args) throws Exception {
        StorageSharedKeyCredential key = new StorageSharedKeyCredential("foo", "AAA=");
        URL url = new URL("https://foo.blob.core.windows.net");
        Map<String, String> headers = new HashMap<>();
        headers.put("Content-Length", "1");
        headers.put("Date", "1");

        long time = System.currentTimeMillis();
        for (int i = 0 ; i < 100000; i++) {
            key.generateAuthorizationHeader(url, "PUT", headers);
        }
        time = System.currentTimeMillis() - time;

        System.out.println("Took " + time + " ms");
    }

Before:
Took 1148 ms

After:
Took 718 ms

@ghost ghost added the Storage Storage Service (Queues, Blobs, Files) label Oct 5, 2021
Copy link
Member

@alzimmermsft alzimmermsft left a comment

Choose a reason for hiding this comment

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

Are the other critical path String.formats being used that could be replaced with this pattern?

@kasobol-msft
Copy link
Contributor Author

Are the other critical path String.formats being used that could be replaced with this pattern?

There are some out there https://github.com/Azure/azure-sdk-for-java/search?q=path%3A%2Fsdk%2Fstorage%2F+%22String.format%22+in%3Afile+extension%3Ajava , setting aside errors, samples and tests there are some that should be revisited but they don't have such a broad impact. I'll create work item for that.

@kasobol-msft kasobol-msft merged commit e62fb55 into Azure:main Oct 5, 2021
@kasobol-msft kasobol-msft deleted the shared-key-format branch October 5, 2021 20:06
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-java that referenced this pull request Jun 24, 2023
Revert "Revert "[Hub Generated] Publish private branch 'azure-kusto/devCM' (Azure#24160)" (Azure#24355)" (Azure#24551)

This reverts commit 6c157d49894462320db6603bb8e7b3077861b2d7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider removing slow String.format call in StorageSharedKeyCredential
5 participants