Repository navigation
Remove fixed sleeps and quadratic array growth in extraction, jobs and reporting - #417
Open
Robin Pieterse (RobinpZA) wants to merge 1 commit into
Open
Robin Pieterse (RobinpZA) wants to merge 1 commit into
Robin Pieterse (RobinpZA) wants to merge 1 commit into
Conversation
…d reporting Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Several places wait a fixed time whatever the work:
Start-ARIProcessJob, once inStart-ARIAutProcessJob), and the automation path sleeps another 5 s afterWait-Jobhas already returned.Wait-ARIJoband the Security/Policy/Advisory/Subscriptions waits inStart-ARIExtraReportspoll withStart-Sleep 5/Start-Sleep 2, so they can oversleep by up to the full interval after the last job finishes.Start-ARIExcelJobsleeps 25 ms per module;Clear-ARIMemorysleeps 200 ms per call;Start-ARIExtraReportsadds 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
Wait-Job -Timeoutinstead ofStart-Sleep, so they return as soon as a job finishes. Progress updates keep the same interval.Clear-ARIMemory(theGCcalls stay).While ($Job.Runspace.IsCompleted -contains $false) { ... }inStart-ARIProcessJob:$JobholdsPowerShellAsyncResultobjects, which have noRunspaceproperty, so the condition was always false and the loop never ran.EndInvokealready waits.Invoke-ARIInventoryLoopandStart-ARIGraphExtractioncollect pages into aList[object]and return an array, as before.Build-ARIExcelComObject(they pace Excel), andGet-ARIAPIResources, which Run per-subscription and per-account Azure calls in parallel #413 rewrites.Verification
Wait-ARIJobwith jobs ending at 2, 4 and 6 s and-LoopTime 5: returns at 10.2 s before, 6.2 s after.+=vs list on 1,000-row pages: 150k rows 236 ms → 3 ms, 500k rows 1.2 s → 16 ms. Small, but it grows quadratically.🤖 Generated with Claude Code
Microsoft Reviewers: Open in CodeFlow