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

Performance: Adds Authorization Helper improvements #2000

Merged
merged 17 commits into from
Nov 18, 2020

Conversation

j82w
Copy link
Contributor

@j82w j82w commented Nov 13, 2020

Pull Request Template

Description

This optimizes the URL encoding by utilizing the fact that the string is always base64 encoded. This also reduces allocations by avoiding converting to a string, back to byte array, url encode the byte array then back to a string. It now takes the original byte array base64 encodes it then url encodes that without the string transformations.

Compares GenerateAuthorizationTokenWithHashCore with HttpUtility.Encode vs new GenerateUrlEncodedAuthorizationTokenWithHashCore

|    Method |     Mean |     Error |    StdDev |    StdErr |      Min |       Q1 |   Median |       Q3 |      Max |      Op/s |  Gen 0 | Gen 1 | Gen 2 | Allocated |
|---------- |---------:|----------:|----------:|----------:|---------:|---------:|---------:|---------:|---------:|----------:|-------:|------:|------:|----------:|
|  Original | 1.923 us | 0.0144 us | 0.0215 us | 0.0039 us | 1.880 us | 1.909 us | 1.920 us | 1.939 us | 1.969 us | 519,947.1 | 0.0992 |     - |     - |     624 B |
| Optimized | 1.783 us | 0.0295 us | 0.0442 us | 0.0081 us | 1.720 us | 1.752 us | 1.774 us | 1.818 us | 1.890 us | 560,700.1 | 0.0534 |     - |     - |     344 B |

MasterKeyAuthorizationBenchmarks

|                       Method |     Mean |     Error |    StdDev |    StdErr |      Min |       Q1 |   Median |       Q3 |      Max |      P80 |      P85 |      P90 |      P95 |     P100 |      Op/s | Completed Work Items | Lock Contentions |  Gen 0 | Gen 1 | Gen 2 | Allocated |
|----------------------------- |---------:|----------:|----------:|----------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|----------:|---------------------:|-----------------:|-------:|------:|------:|----------:|
|    CreateSignatureGeneration | 1.513 us | 0.0091 us | 0.0134 us | 0.0025 us | 1.489 us | 1.502 us | 1.514 us | 1.524 us | 1.538 us | 1.524 us | 1.527 us | 1.530 us | 1.535 us | 1.538 us | 660,796.6 |               0.0000 |                - | 0.0839 |     - |     - |     536 B |
|      ReadSignatureGeneration | 1.508 us | 0.0216 us | 0.0310 us | 0.0059 us | 1.473 us | 1.482 us | 1.502 us | 1.521 us | 1.580 us | 1.530 us | 1.545 us | 1.553 us | 1.567 us | 1.580 us | 663,346.7 |               0.0000 |                - | 0.0839 |     - |     - |     536 B |
| CreateSignatureGenerationOld | 1.785 us | 0.0314 us | 0.0461 us | 0.0086 us | 1.716 us | 1.752 us | 1.777 us | 1.818 us | 1.884 us | 1.827 us | 1.834 us | 1.845 us | 1.862 us | 1.884 us | 560,314.3 |               0.0000 |                - | 0.1259 |     - |     - |     792 B |
|   ReadSignatureGenerationOld | 1.739 us | 0.0300 us | 0.0431 us | 0.0081 us | 1.691 us | 1.709 us | 1.725 us | 1.764 us | 1.854 us | 1.769 us | 1.770 us | 1.794 us | 1.833 us | 1.854 us | 575,021.1 |               0.0000 |                - | 0.1259 |     - |     - |     792 B |

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] This change requires a documentation update

Closing issues

To automatically close an issue: closes #IssueNumber

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Please follow the required format: "[Internal] Category: (Adds|Fixes|Refactors) Description"

Examples:
Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fixes null reference when using default(PartitionKey)
[v4] Client Encryption: Refactors code to external project
[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future.

@j82w j82w changed the title Performance: Authorization Helper improvements Performance: Adds Authorization Helper improvements Nov 13, 2020
@kirankumarkolli
Copy link
Member

Please run it through with Vinod.

ealsur
ealsur previously approved these changes Nov 16, 2020
Copy link
Member

@ealsur ealsur left a comment

Choose a reason for hiding this comment

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

LGTM, just left a comment

@j82w j82w dismissed stale reviews from ealsur and kirankumarkolli via 2e9095d November 17, 2020 15:42
ealsur
ealsur previously approved these changes Nov 17, 2020
@j82w j82w merged commit 4d63666 into master Nov 18, 2020
@j82w j82w deleted the users/jawilley/perf/auth2 branch November 18, 2020 22:55
@ghost
Copy link

ghost commented Dec 15, 2021

Closing due to in-activity, pease feel free to re-open.

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.

4 participants