Skip to content

[Core] Fix #27497: Improve CommandIndex case-insensitive lookup performance#32418

Closed
DanielMicrosoft wants to merge 2 commits intoAzure:devfrom
DanielMicrosoft:35842223-az-version-perf-invstgtn
Closed

[Core] Fix #27497: Improve CommandIndex case-insensitive lookup performance#32418
DanielMicrosoft wants to merge 2 commits intoAzure:devfrom
DanielMicrosoft:35842223-az-version-perf-invstgtn

Conversation

@DanielMicrosoft
Copy link
Copy Markdown
Contributor

@DanielMicrosoft DanielMicrosoft commented Nov 13, 2025

Related command

Description
ADO Task: https://msazure.visualstudio.com/One/_workitems/edit/35842223

Fixes #27497
Closes #27545

This PR implements the same fix proposed in #27545, which has been inactive for over two years. Reopening a fresh PR was simpler and ensures the changes align with the current codebase.

Testing Guide
See ADO task for testing results.

You can see the issue by testing commands with mixed casing (ie az Version) vs (az version) and observing that command index will be re-built in all scenarios when using mixed casing (and obviously a time penalty).

There are comments from @jiasli in Hang's original PR questioning the correct place to normalize arg's, and the load_command_table method takes args and applies roughly_parse_command, there's an argument to be had about applying that earlier (perhaps as soon as args are received in main.py), however that would increase the blast radius of the changes.

This is a targeted approach designed to only target commandIndex lookups to prevent cache misses based on casing.

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


This checklist is used to make sure that common guidelines for a pull request are followed.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Nov 13, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Nov 13, 2025

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Nov 13, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@DanielMicrosoft DanielMicrosoft changed the title add fix with test cases [Core] Fix #27497: Improve CommandIndex case-insensitive lookup performance Nov 13, 2025
@DanielMicrosoft DanielMicrosoft marked this pull request as ready for review November 13, 2025 04:28
Copilot AI review requested due to automatic review settings November 13, 2025 04:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the performance of command index lookups by ensuring case-insensitive command matching. The fix prevents unnecessary command index rebuilds when users enter commands with mixed casing (e.g., az Version vs az version).

Key Changes

  • Added .lower() normalization to the top-level command during command index lookup
  • Introduced comprehensive test coverage for case-insensitive command lookups
  • Updated VS Code debug configurations to use the newer debugpy type

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 10 comments.

File Description
src/azure-cli-core/azure/cli/core/init.py Normalizes command lookup to lowercase to prevent cache misses due to casing differences
src/azure-cli-core/azure/cli/core/tests/test_command_registration.py Adds test coverage for case-insensitive command index lookups with lowercase, uppercase, and mixed case scenarios
.vscode/launch.json Updates debug configurations to use debugpy type and removes deprecated debugOptions, but introduces invalid JSON syntax with trailing commas

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bebound
Copy link
Copy Markdown
Contributor

bebound commented Nov 13, 2025

The reason why #27545 is not merge is that we believe users shouldn't use uppercase in commands.

@DanielMicrosoft
Copy link
Copy Markdown
Contributor Author

The reason why #27545 is not merge is that we believe users shouldn't use uppercase in commands.

hmm ok, thanks for context. Although it doesn't make much sense, as CLI itself will allow any casing when it tries to execute the command, it just means if someone uses any casing other than all lower case, they will get an arbitrary performance hit as we constantly try to re-build the commandIndex?

@DanielMicrosoft DanielMicrosoft deleted the 35842223-az-version-perf-invstgtn branch April 1, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

command index lookup is case sensitive

4 participants