Reduce uploader shutdown stalls and add bounded runtime profiling
CI / verify (push) Canceled after 0s
CI / verify (push) Canceled after 0s
This commit is contained in:
1 parent
80eb878f1b
commit
fe3797fd18
10 files changed
+121
-18
No files matched your search
+10
-1
@@ -1,13 +1,22 @@
|
||||
const os = require('node:os');
|
||||
const { execFile } = require('node:child_process');
|
||||
const { promisify } = require('node:util');
|
||||
const { performance } = require('node:perf_hooks');
|
||||
const { runtimePerformance } = require('./performance-monitor');
|
||||
|
||||
const WINDOWS_PROBE = "$ErrorActionPreference='Stop'; $ProgressPreference='SilentlyContinue'; $d=@(Get-CimInstance Win32_PerfRawData_PerfDisk_PhysicalDisk | ForEach-Object { @{ Name=$_.Name; Timestamp_PerfTime=[string]$_.Timestamp_PerfTime; Frequency_PerfTime=[string]$_.Frequency_PerfTime; Timestamp_Sys100NS=[string]$_.Timestamp_Sys100NS; PercentIdleTime=[string]$_.PercentIdleTime; DiskReadBytesPersec=[string]$_.DiskReadBytesPersec; DiskWriteBytesPersec=[string]$_.DiskWriteBytesPersec; DiskReadsPersec=[string]$_.DiskReadsPersec; DiskWritesPersec=[string]$_.DiskWritesPersec; CurrentDiskQueueLength=[string]$_.CurrentDiskQueueLength } }); $v=@(Get-CimInstance Win32_LogicalDisk -Filter 'DriveType=3' | ForEach-Object { @{ DeviceID=$_.DeviceID; Size=[string]$_.Size; FreeSpace=[string]$_.FreeSpace } }); @{disks=$d;volumes=$v} | ConvertTo-Json -Depth 4 -Compress";
|
||||
|
||||
async function readWindowsCounters({ runner = promisify(execFile), signal } = {}) {
|
||||
const { stdout } = await runner('C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',
|
||||
const started = performance.now();
|
||||
let request;
|
||||
try {
|
||||
request = runner('C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',
|
||||
['-NoLogo', '-NoProfile', '-NonInteractive', '-Command', WINDOWS_PROBE],
|
||||
{ windowsHide: true, shell: false, timeout: 8000, maxBuffer: 1024 * 1024, encoding: 'utf8', signal });
|
||||
} finally {
|
||||
runtimePerformance.record('host.spawn.sync', performance.now() - started);
|
||||
}
|
||||
const { stdout } = await request;
|
||||
const value = JSON.parse(stdout.replace(/^\uFEFF/, ''));
|
||||
if (!Array.isArray(value.disks) || !Array.isArray(value.volumes) || value.disks.length > 256 || value.volumes.length > 256) throw Error('INVALID_METRICS');
|
||||
return value;
|
||||
|
||||
Reference in new issue
Block a user