azure-cli
azure-cli copied to clipboard
Tab completion is incredibly slow and picky about formatting
Describe the bug
Tab completion is painfully slow. See repro.
Command Name
az
Errors:
To Reproduce:
- Properly configure tab completion for your shell, I'm in zsh but this all holds true in bash as well.
- Type
az
in the terminal - Hit tab, it adds a space instead of giving you tab completion.
- Hit tab again, wait 1-2 seconds for tab completion to process
- After a wait, tab completion displays a list of completions.
Another example:
- Type
az devops
oraz boards
in the terminal - Hit tab, wait ~5 seconds
- Get
-- no matches found --
output. - Hit space, hit tab
- Wait ~1s get a bunch of completions
Expected Behavior
A response should be given immediately with no delay and it should not be picky about whether there is a space after the last command.
The entire autocompletion process is way too slow. Type git and hit tab and you get an instant response with completions with nice formatting. This has got to be better in the azure cli. 1-2s is too long, but 5 seconds is just shameful especially having it return no results after, only to work after hitting space.
Please let me know if you need any more information to help prioritize this work, feel free to reach out to me via email or teams via my alias: jiboulte.
Environment Summary
Darwin-18.2.0-x86_64-i386-64bit
Python 3.7.3
Shell: bash
azure-cli 2.0.62
Extensions:
azure-devops 0.4.0
Python location '/usr/local/Cellar/azure-cli/2.0.62/libexec/bin/python'
Extensions directory '/Users/jiboulte/.azure/cliextensions'
Python (Darwin) 3.7.3 (default, Apr 19 2019, 09:07:31)
[Clang 10.0.1 (clang-1001.0.46.3)]
Additional Context
It can't repro on Windows. It may be Mac/Linux only issue.
@jboulter11 , can you try other commands (not az) to see if it has the same issue. I think it may the OS issue not az command issue.
Other commands provide an instant response. az
and its nested commands are what is slow, my OS is fine.
@tjprescott, @limingu, I would be interested in this post build. We should try and imitate powershell. Maddie once mentioned how they cache tab completions...
add to S164.
I second the observation provided here. I'm on a mac, first time using AZ CLI and first thing I noticed is wow, this command completion is super slow. Googled the issue hoping to find a resolution and this issue report is the first thing I came across.
The slowness is due to the fact that auto-complete is achieved by calling az
again with the prefix given in the terminal. Azure CLI now contains thousands of commands and loading these commands makes it slow.
We will try to improve the performance in the future.
13/02/2021 still too slow
This is still extremely slow on Linux.
Python (Linux) 3.9.2 (default, Feb 20 2021, 00:00:00)
[GCC 11.0.0 20210210 (Red Hat 11.0.0-0)]
The CLI autocompletion is still very slow.
E.g.
typing: az stor
hitting: tab
it takes about 10 seconds to complete to "az storage
"
I just installed Ubuntu 20.04 LTE under WFL on a Surface book 3. The Windows OS is fully up to date.
To install the CLI, I used the following simplified command:
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
Is there any recommended configuration under Windows that is known to work properly? E.g. maybe trying with a different distribution or different installation procedure for the cli?
With the introduction of Command Index (https://github.com/Azure/azure-cli/pull/13294), the execution and auto-complete speed of az
has been significantly improved.
On my local machine's Ubuntu 20.04 running on WSL 2, when I type az sto
tab, the auto-complete now takes 1~2 seconds.
Is there any recommended configuration under Windows that is known to work properly?
Auto-complete currently doesn't work on Windows. Are you using WSL instead of "WFL"? In that case, could you try WSL 2 which greatly improves the performance of the Linux subsystem?
Thank you very much Jiashuo. I have moved to WSL 2 and now the autocomplete is very fast. It takes less than a second to complete a command.
@faustinopalma, I am glad to know it works well for you. 😊
Still slow for me is take 1-2 second (WSL2)
Tab completion still slow for me on MacOS 11.16.1.
1~2 seconds for some commands, but that's still far too slow especially when they don't have many options.
Example: Double tab kubectl get
is way faster than az account
double tab.
azure-cli 2.30.0 core 2.30.0 telemetry 1.0.6 Python (Darwin) 3.9.8 (main, Nov 10 2021, 09:21:22) [Clang 13.0.0 (clang-1300.0.29.3)]
Absolutely appalling performance on MacOS. This is completely unacceptable. AWS CLI completion is nearly instantaneous and they have just as many commands, if not more, than you.
Microsoft, please stop developing CLI tools with a Windows first attitude.
On Linux still pretty slow (~2 seconds)
Looks like atleast on Linux az also always makes a call to some Microsoft server whenever I invoke bash completion (Not only when it would provide a useful completion this way)
slow as turtle. regular tasks are so anoying that sometimes I just prefere click-click way. Why don't you guys just fix it, you are MS right :smile: :smile:
same here. On Windows 11 + WSL2. ac account
takes 2-3 seconds. Please fix.
Issue still persist in Win 10 + WSL2
I am surprised that even after more than 3 years the issue has not been resolved. Tab completion is so slow that it is not usable. MS please do something about it or remove the feature. Whats the use of a feature if it is not usable? Tried in both Windows and Linux same result, painfully s.....l......o......w
I looked at this briefly and it seem to have to do with how az
is built fundamentally.
The trouble is that az
(and many of its extensions) are all in python and package all of their dependencies separately, even if some may overlap.
Each time a tab completion event happens in the shell, an az
(python) fork/exec happens to enumerate the options, which (depending on context) may load/parse/interpret/etc. all of the python lib dependencies for each extension as well, which can be massive, and may depend upon which extensions you have downloaded as well (e.g. arcdata
).
Compare this with say aws
(compiled, with a separate completer tool) or kubectl
(compiled, with a cached shell specific completer output) and there is just far less work to do in either of those other two.
Without completely rewriting the basics of how the tool is structured so that it could be compiled, this seems hard to fix.
One possibility is a sort of caching mechanism (perhaps via a separate completer executable) that could potentially enumerate all of the basic tab completion command options (but not local variable/subscription/etc. options) once and only re-evaluate them upon extension or tool addition/upgrade. That would turn the several seconds stall into an infrequent event for tab completions, but would still suffer the couple of seconds to load all the libraries once you actually invoke the command.
Azure-cli uses argcomplete
for completion. It has to executes the underlying script every time TAB
is pressed, so it's slower than other cli tools, but not that much.
The completion time is nearly the same as -h
command. az account -h --debug
takes 0.3s on Ubuntu and 0.8s on WSL2.
@ash-dey which command are you using, could you please send me the output of it with -h --debug
param? If you run it multiple times, does the time decrease?
@bebound - it's no where near that fast on Mac, see below. A second run of --debug
comes back faster, about 1.2s, and it's consistent in subsequent runs so I'm assuming it generates a cache, but this doesn't appear to work for tab completion as from shell, if I double tab to see options it takes between 3 and 10 seconds to return on az aks
ᐅ az aks -h --debug
cli.knack.cli: Command arguments: ['aks', '-h', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x10b4e0550>, <function OutputProducer.on_global_arguments at 0x10b541ab0>, <function CLIQuery.on_global_arguments at 0x10b576ef0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'aks': ['azext_aks_preview', 'azure.cli.command_modules.acs']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: acs 0.532 6 46
cli.azure.cli.core: Total (1) 0.532 6 46
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.knack.cli: Event: CommandLoader.OnLoadCommandTable []
cli.azure.cli.core: aks-preview 0.030 10 60 /Users/Tom.Bailey/.azure/cliextensions/aks-preview
cli.azure.cli.core: Total (1) 0.030 10 60
cli.azure.cli.core: Loaded 12 groups, 73 commands.
cli.azure.cli.core: Found a match in the command group table for 'aks'.
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x10c075090>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/Tom.Bailey/.azure/commands/2022-11-23.09-12-08.aks.335.log'.
az_command_data_logger: command args: aks -h --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x10c14dab0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x10c17c280>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x10c17c3a0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
Group
az aks : Manage Azure Kubernetes Services.
Subgroups:
addon : Commands to manage and view single addon conditions.
command : See detail usage in 'az aks command invoke', 'az aks command
result'.
draft : Commands to build deployment files in a project directory and
deploy to an AKS cluster.
egress-endpoints : Commands to manage egress endpoints in managed Kubernetes
cluster.
maintenanceconfiguration : Commands to manage maintenance configurations in managed
Kubernetes cluster.
nodepool : Commands to manage node pools in managed Kubernetes cluster.
oidc-issuer : Oidc issuer related commands.
pod-identity : Commands to manage pod identities in managed Kubernetes
cluster.
snapshot : Commands to manage cluster snapshots.
Commands:
browse : Show the dashboard for a Kubernetes cluster in a web browser.
check-acr : Validate an ACR is accessible from an AKS cluster.
create : Create a new managed Kubernetes cluster.
delete : Delete a managed Kubernetes cluster.
disable-addons : Disable Kubernetes addons.
enable-addons : Enable Kubernetes addons.
get-credentials : Get access credentials for a managed Kubernetes cluster.
get-os-options : Get the OS options available for creating a managed Kubernetes
cluster.
get-upgrades : Get the upgrade versions available for a managed Kubernetes
cluster.
get-versions : Get the versions available for creating a managed Kubernetes
cluster.
install-cli : Download and install kubectl, the Kubernetes command-line tool.
Download and install kubelogin, a client-go credential (exec)
plugin implementing azure authentication.
kanalyze : Display diagnostic results for the Kubernetes cluster after
kollect is done.
kollect : Collecting diagnostic information for the Kubernetes cluster.
list : List managed Kubernetes clusters.
remove-dev-spaces [Deprecated] : Remove Azure Dev Spaces from a managed Kubernetes
cluster.
rotate-certs : Rotate certificates and keys on a managed Kubernetes cluster.
scale : Scale the node pool in a managed Kubernetes cluster.
show : Show the details for a managed Kubernetes cluster.
start : Starts a previously stopped Managed Cluster.
stop : Stops a Managed Cluster.
update : Update the properties of a managed Kubernetes cluster.
update-credentials : Update credentials for a managed Kubernetes cluster, like
service principal.
upgrade : Upgrade a managed Kubernetes cluster to a newer version.
use-dev-spaces [Deprecated] : Use Azure Dev Spaces with a managed Kubernetes
cluster.
wait : Wait for a managed Kubernetes cluster to reach a desired state.
To search AI knowledge base for examples, use: az find "az aks"
urllib3.connectionpool: Starting new HTTPS connection (1): azure.microsoft.com:443
urllib3.connectionpool: https://azure.microsoft.com:443 "HEAD / HTTP/1.1" 301 0
cli.azure.cli.core.util: Connectivity check: 0.17484789999434724 sec
urllib3.connectionpool: Starting new HTTPS connection (1): raw.githubusercontent.com:443
urllib3.connectionpool: https://raw.githubusercontent.com:443 "GET /Azure/azure-cli/main/src/azure-cli-core/setup.py HTTP/1.1" 200 1246
urllib3.connectionpool: Starting new HTTPS connection (1): raw.githubusercontent.com:443
urllib3.connectionpool: https://raw.githubusercontent.com:443 "GET /Azure/azure-cli/main/src/azure-cli-telemetry/setup.py HTTP/1.1" 200 679
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x10c0752d0>]
az_command_data_logger: exit code: 0
cli.__main__: Command ran in 2.136 seconds (init: 0.599, invoke: 1.537)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3257 in cache
telemetry.check: Returns Positive.
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/usr/local/Cellar/azure-cli/2.42.0/libexec/bin/python /usr/local/Cellar/azure-cli/2.42.0/libexec/lib/python3.10/site-packages/azure/cli/telemetry/__init__.py /Users/Tom.Bailey/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.
@TomBailey-N Thanks for the info. The first run is a bit slow because it checked new version from GitHub. I tried this command on my Mac but I can't reproduce.
What's the output of this command? time IFS=$'\013' COMP_LINE='az aks ' COMP_POINT=6 COMP_TYPE="" _ARGCOMPLETE=1 _ARGCOMPLETE_SUPPRESS_SPACE=1 az 8>&1 9>&2 1>/dev/null 2>/dev/null
Does the command run faster after running az config set core.collect_telemetry=false
?
Still very slow, on the fastest macbook available today.
Any update?
@johnib Can you give me an example of the command when you press <TAB>
?
If the last word is not complete, it’s a lot slower than it should be. I’ve found a way to fix it. For example: az account
is complete, but az account sh
is not complete.
Could you please also compare the speed of complete command, does it run faster?
@johnib Can you give me an example of the command when you press
<TAB>
?If the last word is not complete, for example:
az account
is complete, butaz account sh
is not complete. Could you please also compare the speed of complete command, does it run faster?
are you serious? people who use az cli are sysadmins with good level of knowledge about the console and its use. az cli is very slow tool when compering to any cli tool I use. Hope it will get more usefull one day.
@johnib Can you give me an example of the command when you press
<TAB>
?If the last word is not complete, it’s a lot slower than it should be. I’ve found a way to fix it. For example:
az account
is complete, butaz account sh
is not complete. Could you please also compare the speed of complete command, does it run faster?
Not sure if it ran much faster or not.. it's still slow compared to other CLIs (aws for instance). Not having auto-completion on a CLI significantly reduces usage with it.
Currently I'm using the Az powershell module instead (on a macOS...) just because it's faster in its auto-completion.
Given you acknowledge the slowness, please let us know what are the plans (if at all) and timelines to fix this.
Thank you!
I hope the completion can be finished in 1 second.
For now, the help command reaches the target.
I think argcomplete
can generate completion in the same time, but I'm wrong. I'll do some investigation about it.
The reason why autocomplete is slower than -h
command is the recommendation. It is fixed in https://github.com/Azure/azure-cli/pull/25145
Here is the result of time az account -h
and time IFS=$'\013' COMP_LINE='az account' COMP_POINT=11 COMP_TYPE="" _ARGCOMPLETE=1 _ARGCOMPLETE_SUPPRESS_SPACE=0 az 8>&1 1>&2 2>&2 9>&1
on different OS. It's slow on WSL and Mac.
WSL Ubuntu
0.28s user 0.05s system 79% cpu 0.415 total
0.26s user 0.04s system 36% cpu 0.841 total
Mac
0.18s user 0.06s system 95% cpu 0.246 total
0.20s user 0.06s system 29% cpu 0.858 total
Linux
0.22s user 0.01s system 96% cpu 0.232 total
0.25s user 0.02s system 58% cpu 0.470 total