Conversation
jiasli
commented
Jun 5, 2020
Comment on lines
+851
to
+855
| except Exception as ex: | ||
| # Delay the import and mimic an exception handler | ||
| from msrest.exceptions import ValidationError | ||
| if isinstance(ex, ValidationError): | ||
| logger.debug('Validation error in %s.', str(validator)) |
Member
Author
There was a problem hiding this comment.
Mimic the behavior of
azure-cli/src/azure-cli-core/azure/cli/core/util.py
Lines 58 to 63 in e6e437a
jiasli
commented
Jun 5, 2020
| if full_id_list: | ||
| setattr(namespace, '_ids', full_id_list) | ||
|
|
||
| from azure.mgmt.core.tools import parse_resource_id, is_valid_resource_id |
Member
Author
There was a problem hiding this comment.
Migrate from msrestazure.tools to azure.mgmt.core.tools.
Contributor
|
what's relationship with this PR Performance Boost ? |
Member
Author
This is extracted from #13294 to make reviewing easier. |
haroldrandom
approved these changes
Jun 5, 2020
Contributor
haroldrandom
left a comment
There was a problem hiding this comment.
LGTM. Learnt a lot!
2 tasks
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Previously during CLI initialization, importing these modules are very time-consuming, but actually often unnecessary:
msrestazure.coreazure.mgmt.coreazure.commonThis PR delays the import until these modules are actually used.
The effect is remarkable: For
az verion -h, the import time dropped from 1.755s to 0.648s.Before:

After:

Testing Guide
Generate the import time graph with