perf: skip redundant recursive traversal in provisioning progress polling#6916
perf: skip redundant recursive traversal in provisioning progress polling#6916spboyer wants to merge 3 commits intoAzure:mainfrom
Conversation
…ling Track root operation count and running-ops state between poll cycles. When the operation count is unchanged and no operations are still running, skip the expensive recursive deployment traversal. Keeps 3s poll cadence for near-real-time responsiveness but avoids redundant ARM API calls during the idle tail of long provisioning runs (e.g., waiting for Cosmos DB or Container Apps Environment). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Optimizes provisioning progress polling in the CLI by attempting to skip redundant work between poll cycles when deployment operations appear unchanged, aiming to reduce overhead during long “idle tail” provisioning periods.
Changes:
- Adds
lastRootOpCountandhasRunningOpsstate toProvisioningProgressDisplay. - Introduces an early-return in
ReportProgresswhen operation count hasn’t changed and prior cycle had no running ops. - Updates running-ops tracking at the end of each reporting cycle.
Comments suppressed due to low confidence (3)
cli/azd/pkg/infra/provisioning_progress_display.go:38
- The field name/comment says this tracks the root operation count, but ReportProgress sets it to len(operations) where operations is the fully-recursive list returned by GetDeploymentResourceOperations. Either rename this to reflect what it actually represents, or (if the intent is to avoid recursion) track the root op count separately using a non-recursive fetch.
// Tracks root operation count from the last poll cycle to skip
// expensive recursive traversal when nothing has changed.
lastRootOpCount int
// Whether any operations were still running at last poll.
// When true, we always do the full traversal on next poll.
hasRunningOps bool
cli/azd/pkg/infra/provisioning_progress_display.go:107
- This introduces new stateful skip behavior (lastRootOpCount/hasRunningOps) but there’s no coverage ensuring: (1) first poll doesn’t skip, (2) skips only when count unchanged and no running ops, and (3) does not skip when running ops were present in the prior cycle. Adding targeted unit tests would help prevent regressions and validate the intended perf/UX semantics.
// Quick check: skip processing if nothing has changed since last poll.
// This avoids redundant recursive traversal when the deployment is idle
// (e.g., waiting for a long-running resource to finish).
currentOpCount := len(operations)
if currentOpCount == display.lastRootOpCount && !display.hasRunningOps {
return nil
cli/azd/pkg/infra/provisioning_progress_display.go:109
- The skip check happens after calling ResourceManager.GetDeploymentResourceOperations, which (per its doc/comment) already performs the expensive recursive traversal. As written, this won’t reduce recursive ARM calls or deliver the perf win described in the PR/issue. Consider moving the “did anything change?” check before the recursive call (e.g., fetch only root ops via deployment.Operations or introduce a non-recursive RM method/flag) and only do the recursive traversal when needed.
// Quick check: skip processing if nothing has changed since last poll.
// This avoids redundant recursive traversal when the deployment is idle
// (e.g., waiting for a long-running resource to finish).
currentOpCount := len(operations)
if currentOpCount == display.lastRootOpCount && !display.hasRunningOps {
return nil
}
display.lastRootOpCount = currentOpCount
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Prevents skipping the first poll cycle when zero operations are returned, which would leave users without the initial spinner. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
Skip expensive recursive deployment operation traversal during provisioning progress polling when nothing has changed, while keeping the 3s poll cadence for near-real-time progress.
Closes: #6915
Parent: #6886 (Performance Review Audit -- Finding 9)
Changes
pkg/infra/provisioning_progress_display.go:lastRootOpCountandhasRunningOpstracking fields toProvisioningProgressDisplayBefore / After
The 3% improvement comes from skipping redundant recursive traversals during the idle tail of provisioning (e.g., last ~3 min waiting for Cosmos DB / Container Apps Environment to finish). During this tail, each 3s poll was doing full recursive ARM calls that returned the same data.
Design
Testing
go buildcleantodo-nodejs-mongo-acatemplate