azure-cli: 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:

  1. Properly configure tab completion for your shell, I’m in zsh but this all holds true in bash as well.
  2. Type az in the terminal
  3. Hit tab, it adds a space instead of giving you tab completion.
  4. Hit tab again, wait 1-2 seconds for tab completion to process
  5. After a wait, tab completion displays a list of completions.

Another example:

  1. Type az devops or az boards in the terminal
  2. Hit tab, wait ~5 seconds
  3. Get -- no matches found -- output.
  4. Hit space, hit tab
  5. 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

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 28
  • Comments: 35 (13 by maintainers)

Most upvoted comments

13/02/2021 still too slow

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.

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)]

Other commands provide an instant response. az and its nested commands are what is slow, my OS is fine.

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)]

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.

There is a significant performance improvement in 2.49, please give it a try.

same here. On Windows 11 + WSL2. ac account takes 2-3 seconds. Please fix.

Still slow for me is take 1-2 second (WSL2)

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.

@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.