René's URL Explorer Experiment


Title: Speed up parameter binding by skipping mandatory parameters outside the active parameter set by blakedeckard · Pull Request #28371 · PowerShell/PowerShell · GitHub

Open Graph Title: Speed up parameter binding by skipping mandatory parameters outside the active parameter set by blakedeckard · Pull Request #28371 · PowerShell/PowerShell

X Title: Speed up parameter binding by skipping mandatory parameters outside the active parameter set by blakedeckard · Pull Request #28371 · PowerShell/PowerShell

Description: PR Summary Skip mandatory-parameter bookkeeping for parameters that are not in any of the currently valid parameter sets. For every pipeline object, CmdletParameterBinderController.GetMissingMandatoryParameters loops over each unbound parameter that is mandatory in some parameter set and enumerates its parameter set data, even when the parameter is not in any currently valid set. For commands with many parameter sets this is a large part of the per-object binding cost. Where-Object has 32 parameter sets (one per operator switch) and 32 parameters that are mandatory in one of them, so with the script block parameter set all 31 enumerations find nothing for every input object. The new check is the same one BindUnboundParametersForBindingStateInParameterSet (and several other places) already use: (ParameterSetFlags & _currentParameterSetFlag) == 0 && !IsInAllSets. Since ParameterSetFlags is the OR of all the parameter's set bits and IsInAllSets is set when any of its sets is __AllParameterSets (GenerateParameterSetMappingFromMetadata), GetMatchingParameterSetData returns nothing for such a parameter, so the result is unchanged. PR Context Measured on Linux x64, Release build with ReadyToRun. Each number is the median of 5 alternating process runs; each run takes the fastest of 5 repetitions: Command Before After Change 1..200000 | Where-Object { $_ % 2 } 691 ms 422 ms -39% $objs | Where-Object Tag -eq 3 (50k objects) 132 ms 80 ms -40% 1..200000 | ForEach-Object { $_ } 420 ms 406 ms -3% Per object, measured in-process with [GC]::GetTotalAllocatedBytes and [Diagnostics.Stopwatch]: Command Allocated before Allocated after Change Time before Time after Change 1..200000 | Where-Object { $_ % 2 } 4,464 B 2,232 B -50% 3.45 µs 2.11 µs -39% $objs | Where-Object Tag -eq 3 (50k objects) 3,144 B 912 B -71% 2.65 µs 1.59 µs -40% 1..200000 | ForEach-Object { $_ } 1,936 B 1,792 B -7% 2.10 µs 2.03 µs -3% Allocated bytes were identical in every run. Benchmark script <# .SYNOPSIS Before/after benchmark for "Skip unrelated parameters when checking for missing mandatory parameters". .DESCRIPTION Runs the Before and After pwsh builds in alternating processes (to spread out machine noise), and in each process measures every case in-process with [Diagnostics.Stopwatch] and [GC]::GetTotalAllocatedBytes. Each process reports the best of $Reps repetitions; the script then prints the median across $Rounds processes as two markdown tables. .EXAMPLE ./bench-where-object.ps1 -Before ~/ps-master/release/pwsh -After ~/ps-patched/release/pwsh (Build each with: Start-PSBuild -Configuration Release -Output release) #> param( [Parameter(Mandatory)] [string] $Before, [Parameter(Mandatory)] [string] $After, [int] $Rounds = 5, [int] $Reps = 5 ) # Code that runs inside each child pwsh process. Prints one JSON line. $worker = @' param([int] $Reps) $objs = 1..50000 | ForEach-Object { [pscustomobject]@{ Id = $_; Name = "item$_"; Tag = ($_ % 10) } } $cases = [ordered]@{ '`1..200000 | Where-Object { $_ % 2 }`' = @{ N = 200000; S = { 1..200000 | Where-Object { $_ % 2 } | Out-Null } } '`$objs | Where-Object Tag -eq 3` (50k objects)' = @{ N = 50000; S = { $objs | Where-Object Tag -eq 3 | Out-Null } } '`1..200000 | ForEach-Object { $_ }`' = @{ N = 200000; S = { 1..200000 | ForEach-Object { $_ } | Out-Null } } } $out = [ordered]@{} foreach ($name in $cases.Keys) { $c = $cases[$name] & $c.S; & $c.S # warm up (JIT, caches) $bestMs = [double]::MaxValue; $bestBytes = [long]::MaxValue for ($i = 0; $i -lt $Reps; $i++) { [GC]::Collect(); [GC]::WaitForPendingFinalizers() $a0 = [GC]::GetTotalAllocatedBytes($true) $sw = [Diagnostics.Stopwatch]::StartNew() & $c.S $sw.Stop() $a1 = [GC]::GetTotalAllocatedBytes($true) $bestMs = [Math]::Min($bestMs, $sw.Elapsed.TotalMilliseconds) $bestBytes = [Math]::Min($bestBytes, $a1 - $a0) } $out[$name] = @{ ms = $bestMs; n = $c.N; bytes = $bestBytes } } $out | ConvertTo-Json -Compress -Depth 3 '@ $workerPath = Join-Path ([IO.Path]::GetTempPath()) "bench-where-object-worker.ps1" Set-Content -Path $workerPath -Value $worker $results = @{ Before = @(); After = @() } for ($r = 1; $r -le $Rounds; $r++) { foreach ($side in 'Before', 'After') { $exe = if ($side -eq 'Before') { $Before } else { $After } Write-Host "round $r/$Rounds $side" $json = & $exe -NoProfile -NonInteractive -File $workerPath -Reps $Reps | Select-Object -Last 1 $results[$side] += , ($json | ConvertFrom-Json -AsHashtable) } } function Median([double[]] $v) { $s = $v | Sort-Object; if ($s.Count % 2) { $s[[int][Math]::Floor($s.Count / 2)] } else { ($s[$s.Count / 2 - 1] + $s[$s.Count / 2]) / 2 } } function Pct($a, $b) { '{0:+0;-0;0}%' -f (100 * ($b - $a) / $a) } $names = $results.Before[0].Keys '' "Whole pipeline, median of $Rounds alternating process runs, each the best of $Reps repetitions:" '' '| Command | Before | After | Change |' '|---|---:|---:|---:|' foreach ($n in $names) { $b = Median ($results.Before | ForEach-Object { $_[$n].ms }); $a = Median ($results.After | ForEach-Object { $_[$n].ms }) '| {0} | {1:N0} ms | {2:N0} ms | {3} |' -f ($n -replace '\|', '\|'), $b, $a, (Pct $b $a) } '' 'Per object, measured in-process with `[GC]::GetTotalAllocatedBytes` and `[Diagnostics.Stopwatch]`:' '' '| Command | Allocated before | Allocated after | Change | Time before | Time after | Change |' '|---|---:|---:|---:|---:|---:|---:|' foreach ($n in $names) { $cnt = $results.Before[0][$n].n $bb = Median ($results.Before | ForEach-Object { $_[$n].bytes / $cnt }); $ab = Median ($results.After | ForEach-Object { $_[$n].bytes / $cnt }) $bt = Median ($results.Before | ForEach-Object { $_[$n].ms * 1000 / $cnt }); $at = Median ($results.After | ForEach-Object { $_[$n].ms * 1000 / $cnt }) $bAll = $results.Before | ForEach-Object { [math]::Round($_[$n].bytes / $cnt) } | Sort-Object -Unique $aAll = $results.After | ForEach-Object { [math]::Round($_[$n].bytes / $cnt) } | Sort-Object -Unique '| {0} | {1:N0} B | {2:N0} B | {3} | {4:N2} µs | {5:N2} µs | {6} |' -f ($n -replace '\|', '\|'), $bb, $ab, (Pct $bb $ab), $bt, $at, (Pct $bt $at) if ($bAll.Count -gt 1 -or $aAll.Count -gt 1) { Write-Host "note: allocation varied across runs for $n" } } Remove-Item $workerPath -ErrorAction SilentlyContinue Run: ./bench-where-object.ps1 -Before /pwsh -After /pwsh Testing I have included a debug script below in the first comment to step through the changes. Pester results (engine/ParameterBinding, engine/Basic, Language, Microsoft.PowerShell.Core/Utility/Management) were identical before and after. PR Checklist PR has a meaningful title Use the present tense and imperative mood when describing your changes Summarized changes Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header This PR is ready to merge. Breaking changes None User-facing changes Not Applicable Testing - New and feature N/A or can only be tested interactively (behavior is unchanged; covered by existing parameter binding tests)

Open Graph Description: PR Summary Skip mandatory-parameter bookkeeping for parameters that are not in any of the currently valid parameter sets. For every pipeline object, CmdletParameterBinderController.GetMissingMandat...

X Description: PR Summary Skip mandatory-parameter bookkeeping for parameters that are not in any of the currently valid parameter sets. For every pipeline object, CmdletParameterBinderController.GetMissingMandat...

Opengraph URL: https://github.com/PowerShell/PowerShell/pull/28371

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:a104bb1b-282d-3e84-67d3-3eb1408c7689
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA206:3F5D93:DA1F6:12E488:6AFCDC26
html-safe-noncecebbec1664c03e6bfc659da8721ff2d0e6099d4e6bfa017dc00bf488183a45d9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjA2OjNGNUQ5MzpEQTFGNjoxMkU0ODg6NkFGQ0RDMjYiLCJ2aXNpdG9yX2lkIjoiMjgzMjkzNzE5ODc1ODQ1MjI2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmace8afbb7f992d5e238539e038ba30f052b26a8afd374b3c6702cd4de4e2f6057a
hovercard-subject-tagpull_request:5188205959
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/PowerShell/PowerShell/pull/28371/files
twitter:imagehttps://avatars.githubusercontent.com/u/56769700?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/56769700?s=400&v=4
og:image:altPR Summary Skip mandatory-parameter bookkeeping for parameters that are not in any of the currently valid parameter sets. For every pipeline object, CmdletParameterBinderController.GetMissingMandat...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None0c05b7eb5b95e29725d01bb1f560a020e3fafd0f033c6b9ed3918fa3161254dd
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release79d9154e55368884c8c93766ba4fee076343d37f
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/pull/28371/changes#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fpull%2F28371%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fpull%2F28371%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/pull/28371/changes
Reloadhttps://github.com/PowerShell/PowerShell/pull/28371/changes
Reloadhttps://github.com/PowerShell/PowerShell/pull/28371/changes
PowerShellhttps://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Codehttps://github.com/PowerShell/PowerShell
Issues1.3k (1.3k)https://github.com/PowerShell/PowerShell/issues
Pull requests363 (363)https://github.com/PowerShell/PowerShell/pulls
Discussionshttps://github.com/PowerShell/PowerShell/discussions
Actionshttps://github.com/PowerShell/PowerShell/actions
Projectshttps://github.com/PowerShell/PowerShell/projects
Security and quality3 (3)https://github.com/PowerShell/PowerShell/security
Insightshttps://github.com/PowerShell/PowerShell/insights
Sign up for GitHub https://github.com/signup?return_to=%2FPowerShell%2FPowerShell%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FPowerShell%2FPowerShell%2Fissues%2Fnew%2Fchoose
Blake (blakedeckard)https://github.com/blakedeckard
PowerShell:masterhttps://github.com/PowerShell/PowerShell/tree/master
blakedeckard:perf-where-object-bindinghttps://github.com/blakedeckard/PowerShell/tree/perf-where-object-binding
Conversation 6 https://github.com/PowerShell/PowerShell/pull/28371
Commits 1 https://github.com/PowerShell/PowerShell/pull/28371/commits
Checks 2 https://github.com/PowerShell/PowerShell/pull/28371/checks
Files changed https://github.com/PowerShell/PowerShell/pull/28371/files
Please reload this pagehttps://github.com/PowerShell/PowerShell/pull/28371/changes
Speed up parameter binding by skipping mandatory parameters outside the active parameter set https://github.com/PowerShell/PowerShell/pull/28371/changes#top
Show all changes 1 commit https://github.com/PowerShell/PowerShell/pull/28371/files
f298b36 Skip unrelated parameters when checking for missing mandatory parameters blakedeckard Nov 5, 2026 https://github.com/PowerShell/PowerShell/pull/28371/commits/f298b36e775b08423225554515ebf01cffff082c
Clear filters https://github.com/PowerShell/PowerShell/pull/28371/files
Please reload this pagehttps://github.com/PowerShell/PowerShell/pull/28371/changes
Please reload this pagehttps://github.com/PowerShell/PowerShell/pull/28371/changes
https://github.com/PowerShell/PowerShell/blob/master/.github/CODEOWNERS#L7
src/System.Management.Automation/engine/CmdletParameterBinderController.cshttps://github.com/PowerShell/PowerShell/pull/28371/changes#diff-615448789c060ae3d366101e28f8a865ef104339f272c552dffbb4af7472703d
View file https://github.com/PowerShell/PowerShell/blob/f298b36e775b08423225554515ebf01cffff082c/src/System.Management.Automation/engine/CmdletParameterBinderController.cs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/PowerShell/PowerShell/pull/28371/{{ revealButtonHref }}
https://github.com/PowerShell/PowerShell/pull/28371/changes#diff-615448789c060ae3d366101e28f8a865ef104339f272c552dffbb4af7472703d
https://github.com/PowerShell/PowerShell/pull/28371/changes#diff-615448789c060ae3d366101e28f8a865ef104339f272c552dffbb4af7472703d
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.