Visitar URL original
Remove fixed sleeps and quadratic array growth in extraction, jobs and reporting by RobinpZA · Pull Request #417 · microsoft/ARI · GitHub
Skip to content

Remove fixed sleeps and quadratic array growth in extraction, jobs and reporting - #417

Open
Robin Pieterse (RobinpZA) wants to merge 1 commit into
microsoft:mainfrom
RobinpZA:perf/arrays-sleeps
Open

Robin Pieterse (RobinpZA) wants to merge 1 commit into
microsoft:mainfrom
RobinpZA:perf/arrays-sleeps

Conversation

@RobinpZA

@RobinpZA Robin Pieterse (RobinpZA) commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Several places wait a fixed time whatever the work:

  • Processing jobs sleep 100 ms three times per module (Start-ARIProcessJob, once in Start-ARIAutProcessJob), and the automation path sleeps another 5 s after Wait-Job has already returned.
  • Wait-ARIJob and the Security/Policy/Advisory/Subscriptions waits in Start-ARIExtraReports poll with Start-Sleep 5 / Start-Sleep 2, so they can oversleep by up to the full interval after the last job finishes.
  • Start-ARIExcelJob sleeps 25 ms per module; Clear-ARIMemory sleeps 200 ms per call; Start-ARIExtraReports adds two more 200 ms sleeps.

Resource Graph pages are also collected with $array += $page, which copies the whole array for every 1,000-row page.

Change

  • Polling waits use Wait-Job -Timeout instead of Start-Sleep, so they return as soon as a job finishes. Progress updates keep the same interval.
  • Fixed sleeps removed from processing jobs, Excel module loop, extra reports and Clear-ARIMemory (the GC calls stay).
  • Removed While ($Job.Runspace.IsCompleted -contains $false) { ... } in Start-ARIProcessJob: $Job holds PowerShellAsyncResult objects, which have no Runspace property, so the condition was always false and the loop never ran. EndInvoke already waits.
  • Invoke-ARIInventoryLoop and Start-ARIGraphExtraction collect pages into a List[object] and return an array, as before.
  • Left alone: the Excel COM sleeps in Build-ARIExcelComObject (they pace Excel), and Get-ARIAPIResources, which Run per-subscription and per-account Azure calls in parallel #413 rewrites.

Verification

🤖 Generated with Claude Code

Microsoft Reviewers: Open in CodeFlow

…d reporting

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant