cancel
Showing results for 
Search instead for 
Did you mean: 

REQUEST FOR VOLUNTEERS: Investigating intermittent deep idle state problem

Skip198
Level 8

My ROG FLOW X16 appears to be intermittently entering some kind of deep idle state, as mentioned over here in the Armoury Crate forum: https://rog-forum.asus.com/t5/armoury-crate/rog-flow-x16-a-c-turbo-mode-still-allows-cpu-throttling-...

I've written a Powershell script that is very effective at detecting these idle periods, and I'd really appreciate it if others could volunteer to run the script, and see whether it detects the same issue.  Note that if it does, to be 100% sure it's the same issue, we'd need to use the Windows Performance Recorder to capture the system activity at the time of the idle period. However, if the script does NOT detect the idle, there'd be no need to dig any further - we could conclude that your system does not suffer from the same problem. 
I'm particularly interested those with system architectures as close as possible to mine - i.e - AMD Ryzen 7 6800HS based.

Here's the test procedure:

  1. Do what you would normally do to configure your system for high performance. 
  2. Open a Powershell window, and ensure that script execution is permitted, by running the following command:
     
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted​
  • Save the script (embedded below), and give it a name such as "catch_idle.ps1"
  • Run the script:
./catch_idle.ps1​
  • The script will run indefinitely until it detects the idle period. It may report "soft errors" - they aren't very important to me at the moment.  If it does detect an idle period, it will report the idle time measurement, and will then attempt to stop the Windows Performance Recorder, and will then exit. If you're not running the WPR, it will still report the measurement and exit.
  • Reply here with your results, and your system config. (esp the processor)

The script:

# version 1.0 13-Aug-2025
# Author: Grok (with a bit of guidance from Greg Sullivan greg.sullivan@sullivang.net )

# You may need to issue the following command to allow this script to run:
# Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

# PowerShell script to detect loop delays as follows:
# - Soft failure if delay is between 9-12ms or >=20ms
# - Hard failure if delay is between 13-19ms, which stops WPR and exits the script.
#   (delays in this range are likely to be caused by the mysterious ~14ms idle periods that are being investigated)

# Raise script process priority to High
try {
    $currentProcess = [System.Diagnostics.Process]::GetCurrentProcess()
    $currentProcess.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::High
    Write-Host "Process priority set to High."
}
catch {
    Write-Warning "Failed to set process priority to High: $_"
}


# Define P/Invoke for NtSetTimerResolution
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class TimerResolution {
    [DllImport("ntdll.dll", SetLastError=true)]
    public static extern int NtSetTimerResolution(uint DesiredResolution, bool Set, out uint CurrentResolution);
}
"@

# Set system timer to 1ms resolution (10000 in 100ns units)
$currentResolution = 0
try {
    $timerResult = [TimerResolution]::NtSetTimerResolution(10000, $true, [ref]$currentResolution)
    if ($timerResult -ne 0) {
        Write-Warning "Failed to set timer resolution to 1ms (status: $timerResult). Continuing with default resolution."
    }
    else {
        Write-Host "Timer resolution set to 1ms (current: $($currentResolution/10000)ms)."
    }
}
catch {
    Write-Warning "Error setting timer resolution: $_ Continuing with default resolution."
}

# Counter for total iterations
$totalIterations = 0

# Main loop
try {
    while ($true) {
        $start = [System.Diagnostics.Stopwatch]::StartNew()
        # Precise sleep for 1ms
        [System.Threading.Thread]::Sleep(1)
        $elapsedMs = [math]::Round($start.Elapsed.TotalMilliseconds)
        $totalIterations++
        
        # Check delay categories
        if ($elapsedMs -ge 9 -and $elapsedMs -le 12 -or $elapsedMs -ge 20) {
            Write-Host "Soft failure: $elapsedMs ms"
        }
        elseif ($elapsedMs -ge 13 -and $elapsedMs -le 19) {
            Write-Host "Loop delay exceeded 10ms: $elapsedMs ms"
            
            # Spawn process to stop WPR
            try {
                Write-Host "Stopping WPR..."
                Start-Process -FilePath "wpr" -ArgumentList "-stop WPRRecording.etl" -NoNewWindow -Wait
                Write-Host "WPR stopped. ETL file saved to: WPRRecording.etl"
            }
            catch {
                Write-Error "Failed to stop WPR: $_"
            }
            
            # Exit the script
            Write-Host "Exiting script after $totalIterations iterations."
            exit
        }
        
    }
}
finally {
    # Restore default timer resolution
    try {
        $currentResolution = 0
        $timerResult = [TimerResolution]::NtSetTimerResolution(0, $false, [ref]$currentResolution)
        if ($timerResult -ne 0) {
            Write-Warning "Failed to restore default timer resolution (status: $timerResult)."
        }
        else {
            Write-Host "Timer resolution restored."
        }
    }
    catch {
        Write-Warning "Error restoring timer resolution: $_"
    }
}
333 Views
1 REPLY 1

Skip198
Level 8

Oh - while you're running the script, do what you like - just use the system normally.  I find that simply opening & closing apps makes it fail pretty quickly (within minutes)