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

{Core} Optimize performance for MSAL migration #19898

Merged
merged 2 commits into from
Oct 15, 2021
Merged

{Core} Optimize performance for MSAL migration #19898

merged 2 commits into from
Oct 15, 2021

Conversation

jiasli
Copy link
Member

@jiasli jiasli commented Oct 15, 2021

Description

As authentication logic is now split from Profile, performance can be further improved by lazy loading .auth.identity module.

> Measure-Command {python -m azure.cli version}
TotalMilliseconds : 384.9338

> Measure-Command {az version}
TotalMilliseconds : 404.2362

Imported modules can be inspected with

python -X importtime -m azure.cli version 2>perf.log; tuna .\perf.log

image

@jiasli jiasli requested a review from evelyn-ys as a code owner October 15, 2021 06:04
Comment on lines +105 to +109
# Importing azure.core.credentials.AccessToken is expensive.
# This can slow down commands that doesn't need azure.core, like `az account get-access-token`.
# So We define our own AccessToken.
from collections import namedtuple
AccessToken = namedtuple("AccessToken", ["token", "expires_on"])
Copy link
Member Author

Choose a reason for hiding this comment

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

This can eliminate the Azure Core import time:

python -X importtime -m azure.cli account get-access-token 2>perf.log; tuna .\perf.log

image

# Before
> Measure-Command {python -m azure.cli account get-access-token}
TotalMilliseconds : 1281.14

# After
> Measure-Command {python -m azure.cli account get-access-token}
TotalMilliseconds : 1070.6358

@jiasli jiasli self-assigned this Oct 15, 2021
@jiasli jiasli added the MSAL label Oct 15, 2021
@yonzhan
Copy link
Collaborator

yonzhan commented Oct 15, 2021

performance Optimization

@jiasli jiasli requested review from calvinhzy and yonzhan October 15, 2021 06:14
@yonzhan yonzhan added this to the Oct 2021 (2021-11-02) milestone Oct 15, 2021
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