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: Optimization for master-key authentication #14163

Merged
merged 15 commits into from
Aug 19, 2020

Conversation

kirankumarkolli
Copy link
Member

@kirankumarkolli kirankumarkolli commented Aug 17, 2020

Key optimizations cover yields 0.3% CPU

  • Reusing the mac instances
  • Use object == to avoid hash computation

Baseline:
image

With optimization:
image


class MacPool {
final Mac macInstance;
final ConcurrentLinkedQueue<Mac> pool;
Copy link
Contributor

@moderakh moderakh Aug 19, 2020

Choose a reason for hiding this comment

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

Using MacPool is a very nice change.

however now mac.clone() overhead is replaced by a ConcurrentLinkedQueue synchrnozation lock overhead. most likely better perf.

on the perf comparison do we know how much of perf gain we have from this?

You can do micro-benchmarking using jmh (just for the authorization part) I have the jmh project template here:
https://github.com/moderakh/azure-cosmosdb-benchmark/tree/master/jmh

Copy link
Member Author

Choose a reason for hiding this comment

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

Won't this benchmark needs package to be published?

Copy link
Contributor

Choose a reason for hiding this comment

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

no, you don't need to publish the package. There are two options:

first option)
on the java SDK repo install the package in your local maven repo using following command:
mvn -e -Dgpg.skip -Dmaven.javadoc.skip=true -Dspotbugs.skip=true -Dcheckstyle.skip=true -Drevapi.skip=true -DskipTests -pl ,com.azure:azure-cosmos -am clean install
and in the jmh project just update the pom to use the latest version installed in your local maven repo.
example for this option in jmh project:
https://github.com/moderakh/azure-cosmosdb-benchmark/blob/master/jmh/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdTokenStreamJMH.java

second option)
if the area to be tested is small (just copy that code (e.g, MacPool) to jmh project itself and micro benchmark just the copied code.
example for this option:
copied code:
https://github.com/moderakh/azure-cosmosdb-benchmark/blob/master/jmh/src/main/java/moderakh/ConsistencyLevel.java
micro-benchmark test:
https://github.com/moderakh/azure-cosmosdb-benchmark/blob/master/jmh/src/main/java/moderakh/ExpandableStringEnumJMH.java

Copy link
Member Author

Choose a reason for hiding this comment

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

Based on offline discussion resolving this comment.

Copy link
Contributor

@moderakh moderakh left a comment

Choose a reason for hiding this comment

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

Looks good to me.

on the perf comparison do we know how much of perf gain we have from this?

Using MacPool is a very nice change.

however now mac.clone() overhead is replaced by a synchrnozation lock. most likely better perf. but do we know how much perf gain?

You can do micro-benchmarking using jmh (just for the authorization part) I have the jmh project template here:
https://github.com/moderakh/azure-cosmosdb-benchmark/tree/master/jmh

# Conflicts:
#	sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/BaseAuthorizationTokenProvider.java
@kirankumarkolli kirankumarkolli merged commit a7fa438 into master Aug 19, 2020
@kirankumarkolli kirankumarkolli deleted the users/kirankk/base_auth_perf_fixes branch August 19, 2020 18:55
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-java that referenced this pull request May 14, 2021
machinelearningcompute wave4 modification (Azure#14163)

* machinelearningcompute wave4 modification

* machinelearningcompute wave4

* only track2

* 1.0.0b1

Co-authored-by: Yan Zhang (WICRESOFT NORTH AMERICA LTD) <[email protected]>
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.

3 participants