mgmt resources, optimize logic to load SDK version property #47283
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Goal
This PR isn't likely to fix the thread block, as it's still in reproduction.
What this PR is trying to do, is to at least lower the times needed to read from disk to an exponential degree.
Previously, for each
AzureServiceClientinstance, we need to read from disk once. If there be 100 clients, and 1000AzureResourceManagerinstantiations, there would be 100 * 1000 = 100,000 disk reads.Now it's at most 20+(number of the premium libraries).
Choices
The idea is to cache the result so that it would be available in next version request.
There are basically 3 timings to load the cache:
AzureServiceClientsubclasses get loaded by classloaders.AzureServiceClientgot instantiated through, e.g.new xx().Option 1 is most efficient, and most likely to solve the thread block, as there will be no concurrent issues, since classloader will always operation on single thread. Though the downside is that we probably need to modify codegen to add some kind of registration in all subclasses instantiation, e.g. through static block, which affects a lot.
Difference between option 2 and 3 is whether to pre-load caches during class instantiation.
This PR did option2, with assumption that concurrent method calls are more intensive than concurrent class instantiations, while also no need to touch all
AzureServiceClientsubclasses.Result
Before this PR, concurrent initialization of 1000
AzureResourceManagers on 1000 threads takes roughly 8 seconds on my mac.This PR reduces it to 2 seconds.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines