categories/Performance.ps1
|
# Performance category: SvcHostSplitThresholdInKB, Win32PrioritySeparation, keyboard # delay/speed, MMCSS SystemResponsiveness/NetworkThrottlingIndex. research.md -> performance # category table. function Get-OctaPerformanceCategory { [CmdletBinding()] param() return [pscustomobject]@{ Id = 'performance' DisplayName = 'Performance' Description = 'svchost/priority/keyboard/MMCSS tuning' RequiresElevation = $true ContainsIrreversibleActions = $false GetActionsFunction = 'Get-OctaPerformanceActions' ApplyActionFunction = 'Set-OctaPerformanceAction' } } function Get-OctaPerformanceActions { [CmdletBinding()] param() $actions = @() # SvcHostSplitThresholdInKB - Safe (Windows already auto-applies this above ~3.5GB RAM; # this only does anything on older/constrained configurations). $svcHostKey = 'HKLM:\SYSTEM\CurrentControlSet\Control' $ramKb = [int64]((Get-CimInstance -ClassName Win32_ComputerSystem).TotalPhysicalMemory / 1024) $currentThreshold = (Get-ItemProperty -Path $svcHostKey -Name 'SvcHostSplitThresholdInKB' -ErrorAction SilentlyContinue).SvcHostSplitThresholdInKB if ($null -eq $currentThreshold -or $currentThreshold -ne $ramKb) { $displayCurrent = if ($null -eq $currentThreshold) { '(not set)' } else { $currentThreshold } $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$svcHostKey|SvcHostSplitThresholdInKB" ` -CurrentValue $displayCurrent -PlannedValue $ramKb -Reversible $true -RiskLevel Safe } # Win32PrioritySeparation - Moderate (system-wide scheduling behavior, not cosmetic). $priorityKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\PriorityControl' $currentPriority = (Get-ItemProperty -Path $priorityKey -Name 'Win32PrioritySeparation' -ErrorAction SilentlyContinue).Win32PrioritySeparation if ($null -eq $currentPriority -or $currentPriority -ne 38) { $displayCurrent = if ($null -eq $currentPriority) { '(not set)' } else { $currentPriority } $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$priorityKey|Win32PrioritySeparation" ` -CurrentValue $displayCurrent -PlannedValue 38 -Reversible $true -RiskLevel Moderate } # Keyboard delay/speed - Safe (per-user preference, HKCU). $kbKey = 'HKCU:\Control Panel\Keyboard' $currentDelay = (Get-ItemProperty -Path $kbKey -Name 'KeyboardDelay' -ErrorAction SilentlyContinue).KeyboardDelay if ($null -eq $currentDelay -or $currentDelay -ne '0') { $displayCurrent = if ($null -eq $currentDelay) { '(not set)' } else { $currentDelay } $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$kbKey|KeyboardDelay" ` -CurrentValue $displayCurrent -PlannedValue '0' -Reversible $true -RiskLevel Safe } $currentSpeed = (Get-ItemProperty -Path $kbKey -Name 'KeyboardSpeed' -ErrorAction SilentlyContinue).KeyboardSpeed if ($null -eq $currentSpeed -or $currentSpeed -ne '31') { $displayCurrent = if ($null -eq $currentSpeed) { '(not set)' } else { $currentSpeed } $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$kbKey|KeyboardSpeed" ` -CurrentValue $displayCurrent -PlannedValue '31' -Reversible $true -RiskLevel Safe } # MMCSS - Moderate (removes/lowers a background-task scheduling reservation). $mmcssKey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile' $currentResponsiveness = (Get-ItemProperty -Path $mmcssKey -Name 'SystemResponsiveness' -ErrorAction SilentlyContinue).SystemResponsiveness if ($null -eq $currentResponsiveness -or $currentResponsiveness -ne 0) { $displayCurrent = if ($null -eq $currentResponsiveness) { '(not set)' } else { $currentResponsiveness } $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$mmcssKey|SystemResponsiveness" ` -CurrentValue $displayCurrent -PlannedValue 0 -Reversible $true -RiskLevel Moderate } $currentThrottling = (Get-ItemProperty -Path $mmcssKey -Name 'NetworkThrottlingIndex' -ErrorAction SilentlyContinue).NetworkThrottlingIndex if ($null -eq $currentThrottling -or $currentThrottling -ne 0xffffffff) { $displayCurrent = if ($null -eq $currentThrottling) { '(not set)' } else { $currentThrottling } $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$mmcssKey|NetworkThrottlingIndex" ` -CurrentValue $displayCurrent -PlannedValue 0xffffffff -Reversible $true -RiskLevel Moderate } return $actions } function Set-OctaPerformanceAction { [CmdletBinding()] param([Parameter(Mandatory)]$Action) $keyPath, $valueName = $Action.TargetIdentifier -split '\|', 2 if (-not (Test-Path $keyPath)) { New-Item -Path $keyPath -Force | Out-Null } $type = if ($valueName -in @('KeyboardDelay', 'KeyboardSpeed')) { 'String' } else { 'DWord' } Set-ItemProperty -Path $keyPath -Name $valueName -Value $Action.PlannedValue -Type $type } |