Created
November 4, 2026 09:08
-
-
Save Pyseph/a00849f26f95d5a9b00dac41fe4279c5 to your computer and use it in GitHub Desktop.
Raw timings, process trees and failure runs for the t3code knip:check side-by-side change (Windows)
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
| # Fair timing of `vp run knip:check`: main's script (worktree -Main) vs this branch (worktree -Branch). | |
| # Alternates main/branch, -Runs times each, for each CPU count. Every run: | |
| # * creates a Windows job object whose AFFINITY limit is the mask (first N logical CPUs) and whose priority class is | |
| # below-normal, and assigns the started process to it right after start; the kernel then applies both to every | |
| # descendant. (Setting the mask on processes directly does not stick on this machine: something resets it to | |
| # all CPUs within about a second, and Start-Process children do not inherit it. The job limit cannot be reset.) | |
| # * samples the whole process tree (every descendant of the started process) about every 100 ms plus the cost of | |
| # the sample, sums the working sets of all of them, and keeps the maximum of the sum; | |
| # * records start time (UTC), requested mask, the mask a sampled descendant reports during the run, exit | |
| # code, seconds, peak summed working set, process count at the peak, sample count and mean sample interval, | |
| # and (OutTree) the names and PIDs of the process tree at the peak. | |
| # Usage: powershell -File bench-knip.ps1 -Main <dir> -Branch <dir> -OutCsv <file> -OutTree <file> [-Cpus 4,8] [-Runs 5] [-Warmup] | |
| # vp must be on PATH; the command is `vp env exec --node 26.12.1 vp run knip:check` run in the given directory. | |
| param( | |
| [Parameter(Mandatory)][string]$Main, [Parameter(Mandatory)][string]$Branch, | |
| [Parameter(Mandatory)][string]$OutCsv, [Parameter(Mandatory)][string]$OutTree, | |
| [int[]]$Cpus = @(4, 8), [int]$Runs = 5, [switch]$Warmup, [string]$Node = "26.12.1" | |
| ) | |
| $ErrorActionPreference = "Stop" | |
| Add-Type -TypeDefinition @' | |
| using System; using System.Runtime.InteropServices; | |
| public static class JobAff { | |
| [StructLayout(LayoutKind.Sequential)] struct BASIC { public long PerProcessUserTimeLimit, PerJobUserTimeLimit; public uint LimitFlags; public UIntPtr MinWs, MaxWs; public uint ActiveProcessLimit; public UIntPtr Affinity; public uint PriorityClass, SchedulingClass; } | |
| [StructLayout(LayoutKind.Sequential)] struct IO { public ulong a,b,c,d,e,f; } | |
| [StructLayout(LayoutKind.Sequential)] struct EXT { public BASIC Basic; public IO Io; public UIntPtr ProcMem, JobMem, PeakProc, PeakJob; } | |
| [DllImport("kernel32.dll", CharSet=CharSet.Unicode)] static extern IntPtr CreateJobObject(IntPtr a, string n); | |
| [DllImport("kernel32.dll")] static extern bool SetInformationJobObject(IntPtr j, int c, ref EXT i, int len); | |
| [DllImport("kernel32.dll")] static extern bool AssignProcessToJobObject(IntPtr j, IntPtr p); | |
| [DllImport("kernel32.dll")] public static extern bool CloseHandle(IntPtr h); | |
| public static IntPtr Create(ulong mask) { | |
| IntPtr j = CreateJobObject(IntPtr.Zero, null); EXT e = new EXT(); | |
| e.Basic.LimitFlags = 0x10 | 0x20; e.Basic.Affinity = new UIntPtr(mask); e.Basic.PriorityClass = 0x4000; | |
| if (!SetInformationJobObject(j, 9, ref e, Marshal.SizeOf(typeof(EXT)))) throw new Exception("SetInformationJobObject " + Marshal.GetLastWin32Error()); | |
| return j; } | |
| public static void Assign(IntPtr j, IntPtr proc) { if (!AssignProcessToJobObject(j, proc)) throw new Exception("Assign " + Marshal.GetLastWin32Error()); } | |
| } | |
| '@ | |
| if (-not (Test-Path $OutCsv)) { | |
| "cpus,run,variant,start_utc,mask_requested_hex,mask_seen_on_descendant_hex,exit,seconds,peak_tree_ws_mb,procs_at_peak,max_procs,samples,mean_sample_ms,knip_procs_max,other_masks_seen" | Set-Content $OutCsv | |
| } | |
| function Get-Tree([int]$rootPid, $procs, $notBefore) { | |
| $ids = New-Object 'System.Collections.Generic.HashSet[int]'; [void]$ids.Add($rootPid) | |
| do { $added = $false | |
| foreach ($p in $procs) { if ($p.CreationDate -ge $notBefore -and $ids.Contains([int]$p.ParentProcessId) -and $ids.Add([int]$p.ProcessId)) { $added = $true } } | |
| } while ($added) | |
| , $ids | |
| } | |
| function Invoke-One($dir, [int]$cpus, [string]$variant, [int]$run, [bool]$record) { | |
| $mask = [uint64]([math]::Pow(2, $cpus) - 1) | |
| $job = [JobAff]::Create($mask) | |
| $start = [DateTime]::UtcNow; $notBefore = [DateTime]::Now.AddSeconds(-1) # ignores reused parent PIDs of older processes | |
| $sw = [Diagnostics.Stopwatch]::StartNew() | |
| $p = Start-Process -FilePath "vp.exe" -WorkingDirectory $dir -PassThru -NoNewWindow ` | |
| -ArgumentList @("env", "exec", "--node", $Node, "vp", "run", "knip:check") ` | |
| -RedirectStandardOutput "$OutTree.stdout" -RedirectStandardError "$OutTree.stderr" | |
| $null = $p.Handle | |
| [JobAff]::Assign($job, $p.Handle) | |
| $peak = 0L; $peakProcs = 0; $maxProcs = 0; $knipMax = 0; $n = 0; $peakDesc = ""; $seen = 0L; $others = New-Object 'System.Collections.Generic.HashSet[string]' | |
| while (-not $p.HasExited) { | |
| $procs = Get-CimInstance Win32_Process -Property ProcessId, ParentProcessId, WorkingSetSize, Name, CommandLine, CreationDate | |
| $ids = Get-Tree $p.Id $procs $notBefore | |
| $sum = 0L; $cnt = 0; $knip = 0; $desc = New-Object System.Collections.Generic.List[string] | |
| foreach ($q in $procs) { | |
| if ($ids.Contains([int]$q.ProcessId)) { | |
| $sum += [int64]$q.WorkingSetSize; $cnt++ | |
| $desc.Add("$($q.Name):$($q.ProcessId)") | |
| if ($q.CommandLine -and $q.CommandLine -match 'knip') { $knip++ } | |
| } | |
| } | |
| $n++ | |
| if ($cnt -gt $maxProcs) { $maxProcs = $cnt } | |
| if ($knip -gt $knipMax) { $knipMax = $knip } | |
| if ($sum -gt $peak) { $peak = $sum; $peakProcs = $cnt; $peakDesc = ($desc -join " ") } | |
| if ($n % 10 -eq 5) { # spot-check the mask of a few descendants | |
| foreach ($id in ($ids | Select-Object -Last 3)) { try { $m = [uint64][int64](Get-Process -Id $id -ErrorAction Stop).ProcessorAffinity; $seen = $m; if ($m -ne $mask) { [void]$others.Add(("{0}=0x{1:X}" -f $id, $m)) } } catch {} } | |
| } | |
| Start-Sleep -Milliseconds 100 | |
| } | |
| $sw.Stop(); $p.WaitForExit(); [void][JobAff]::CloseHandle($job) | |
| if (-not $record) { return } | |
| $row = "{0},{1},{2},{3:o},0x{4:X},0x{5:X},{6},{7:N2},{8},{9},{10},{11},{12:N0},{13},{14}" -f $cpus, $run, $variant, $start, | |
| $mask, $seen, $p.ExitCode, $sw.Elapsed.TotalSeconds, [math]::Round($peak / 1MB), $peakProcs, $maxProcs, $n, | |
| ($sw.Elapsed.TotalMilliseconds / [math]::Max($n, 1)), $knipMax, ($others -join "|") | |
| Add-Content $OutCsv $row | |
| Add-Content $OutTree "cpus=$cpus run=$run variant=$variant start=$($start.ToString('o')) peak_tree: $peakDesc" | |
| } | |
| foreach ($c in $Cpus) { | |
| if ($Warmup) { Invoke-One $Main $c "main" 0 $false; Invoke-One $Branch $c "branch" 0 $false } | |
| for ($r = 1; $r -le $Runs; $r++) { | |
| Invoke-One $Main $c "main" $r $true | |
| Invoke-One $Branch $c "branch" $r $true | |
| } | |
| } |
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
| # vp test run --project root scripts/check-changed.test.ts, with the NodeOS.devNull values in the test file temporarily replaced by "/dev/null" (Git for Windows rejects the Windows null device path); reverted afterwards. | |
| note: You are running `vp test` as a Vite+ built-in command. If you meant to run the test npm script, use `vpr test` instead. | |
| RUN v5.0.5 <worktree> | |
| hint: Using 'master' as the name for the initial branch. This default branch name | |
| hint: is subject to change. To configure the initial branch name to use in all | |
| hint: of your new repositories, which will suppress this warning, call: | |
| hint: | |
| hint: git config --global init.defaultBranch <name> | |
| hint: | |
| hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and | |
| hint: 'development'. The just-created branch can be renamed via this command: | |
| hint: | |
| hint: git branch -m <name> | |
| hint: Using 'master' as the name for the initial branch. This default branch name | |
| hint: is subject to change. To configure the initial branch name to use in all | |
| hint: of your new repositories, which will suppress this warning, call: | |
| hint: | |
| hint: git config --global init.defaultBranch <name> | |
| hint: | |
| hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and | |
| hint: 'development'. The just-created branch can be renamed via this command: | |
| hint: | |
| hint: git branch -m <name> | |
| hint: Using 'master' as the name for the initial branch. This default branch name | |
| hint: is subject to change. To configure the initial branch name to use in all | |
| hint: of your new repositories, which will suppress this warning, call: | |
| hint: | |
| hint: git config --global init.defaultBranch <name> | |
| hint: | |
| hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and | |
| hint: 'development'. The just-created branch can be renamed via this command: | |
| hint: | |
| hint: git branch -m <name> | |
| Test Files 1 passed (1) | |
| Tests 15 passed (15) | |
| Start at 07:30:27 | |
| Duration 17.31s (tests 96%, import 3%, setup 1%) | |
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
| main | file | exit=1 | seconds=11.0653 | |
|---|---|---|---|---|
| main | export | exit=1 | seconds=29.107 | |
| main | both-1 | exit=1 | seconds=10.848 | |
| branch | file | exit=1 | seconds=12.0331 | |
| branch | export | exit=1 | seconds=20.7638 | |
| branch | both-1 | exit=1 | seconds=11.5226 | |
| branch | both-2 | exit=1 | seconds=11.6029 | |
| branch | both-3 | exit=1 | seconds=11.8316 |
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
| cpus | run | variant | start_utc | mask_requested_hex | mask_seen_on_descendant_hex | exit | seconds | peak_tree_ws_mb | procs_at_peak | max_procs | samples | mean_sample_ms | knip_procs_max | other_masks_seen | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 4 | 1 | main | 2026-11-04T06:41:33.2378118Z | 0xF | 0xF | 0 | 38.26 | 3341 | 7 | 10 | 122 | 314 | 7 | ||
| 4 | 1 | branch | 2026-11-04T06:42:11.5150842Z | 0xF | 0xF | 0 | 26.60 | 3343 | 7 | 9 | 86 | 309 | 9 | ||
| 4 | 2 | main | 2026-11-04T06:42:38.1215497Z | 0xF | 0xF | 0 | 35.27 | 3306 | 7 | 10 | 132 | 267 | 7 | ||
| 4 | 2 | branch | 2026-11-04T06:43:13.3969458Z | 0xF | 0xF | 0 | 25.30 | 3313 | 7 | 9 | 100 | 253 | 9 | ||
| 4 | 3 | main | 2026-11-04T06:43:38.6946092Z | 0xF | 0xF | 0 | 33.58 | 3312 | 7 | 7 | 135 | 249 | 7 | ||
| 4 | 3 | branch | 2026-11-04T06:44:12.2805326Z | 0xF | 0xF | 0 | 26.17 | 3331 | 7 | 10 | 102 | 257 | 9 | 5228=0x0 | |
| 4 | 4 | main | 2026-11-04T06:44:38.4485249Z | 0xF | 0xF | 0 | 34.26 | 3347 | 7 | 7 | 128 | 268 | 7 | ||
| 4 | 4 | branch | 2026-11-04T06:45:12.7131015Z | 0xF | 0xF | 0 | 25.80 | 3335 | 7 | 11 | 85 | 304 | 9 | ||
| 4 | 5 | main | 2026-11-04T06:45:38.5158378Z | 0xF | 0xF | 0 | 34.20 | 3352 | 7 | 9 | 119 | 287 | 7 | ||
| 4 | 5 | branch | 2026-11-04T06:46:12.7189893Z | 0xF | 0xF | 0 | 26.16 | 3340 | 7 | 9 | 87 | 301 | 9 | ||
| 8 | 1 | main | 2026-11-04T06:47:35.0313481Z | 0xFF | 0xFF | 0 | 32.90 | 3320 | 7 | 7 | 119 | 276 | 7 | 49584=0x0 | |
| 8 | 1 | branch | 2026-11-04T06:48:07.9363219Z | 0xFF | 0xFF | 0 | 22.19 | 3318 | 7 | 12 | 79 | 281 | 9 | ||
| 8 | 2 | main | 2026-11-04T06:48:30.1282730Z | 0xFF | 0xFF | 0 | 33.91 | 3301 | 7 | 8 | 117 | 290 | 7 | ||
| 8 | 2 | branch | 2026-11-04T06:49:04.0369118Z | 0xFF | 0xFF | 0 | 23.01 | 3319 | 7 | 9 | 82 | 281 | 9 | ||
| 8 | 3 | main | 2026-11-04T06:49:27.0455541Z | 0xFF | 0xFF | 0 | 32.78 | 3376 | 7 | 7 | 113 | 290 | 7 | ||
| 8 | 3 | branch | 2026-11-04T06:49:59.8271091Z | 0xFF | 0xFF | 0 | 23.13 | 3354 | 7 | 11 | 74 | 313 | 9 | ||
| 8 | 4 | main | 2026-11-04T06:50:22.9666997Z | 0xFF | 0xFF | 0 | 35.64 | 3313 | 7 | 7 | 109 | 327 | 7 | ||
| 8 | 4 | branch | 2026-11-04T06:50:58.6084152Z | 0xFF | 0xFF | 0 | 23.61 | 3373 | 7 | 9 | 70 | 337 | 9 | ||
| 8 | 5 | main | 2026-11-04T06:51:22.2199601Z | 0xFF | 0xFF | 0 | 34.22 | 3382 | 7 | 7 | 107 | 320 | 7 | ||
| 8 | 5 | branch | 2026-11-04T06:51:56.4457657Z | 0xFF | 0xFF | 0 | 22.23 | 3352 | 7 | 9 | 72 | 309 | 9 |
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
| cpus=4 run=1 variant=main start=2026-11-04T06:41:33.2378118Z peak_tree: vp.exe:34224 vp.exe:17612 vp.exe:23960 vp.exe:45916 node.exe:10500 cmd.exe:21424 node.exe:36788 | |
| cpus=4 run=1 variant=branch start=2026-11-04T06:42:11.5150842Z peak_tree: vp.exe:6848 vp.exe:44068 vp.exe:28036 vp.exe:6132 node.exe:35788 cmd.exe:2972 node.exe:39432 | |
| cpus=4 run=2 variant=main start=2026-11-04T06:42:38.1215497Z peak_tree: vp.exe:15852 vp.exe:35888 vp.exe:56612 vp.exe:26548 node.exe:51564 cmd.exe:57188 node.exe:33408 | |
| cpus=4 run=2 variant=branch start=2026-11-04T06:43:13.3969458Z peak_tree: vp.exe:53700 vp.exe:43344 vp.exe:34664 vp.exe:50576 node.exe:10988 cmd.exe:23932 node.exe:53432 | |
| cpus=4 run=3 variant=main start=2026-11-04T06:43:38.6946092Z peak_tree: vp.exe:53320 vp.exe:26992 vp.exe:49444 vp.exe:51932 node.exe:25960 cmd.exe:9092 node.exe:17620 | |
| cpus=4 run=3 variant=branch start=2026-11-04T06:44:12.2805326Z peak_tree: vp.exe:5484 vp.exe:20408 vp.exe:15844 vp.exe:53796 node.exe:21960 cmd.exe:54420 node.exe:52640 | |
| cpus=4 run=4 variant=main start=2026-11-04T06:44:38.4485249Z peak_tree: vp.exe:47028 vp.exe:9700 vp.exe:28572 vp.exe:54908 node.exe:7776 cmd.exe:25216 node.exe:19264 | |
| cpus=4 run=4 variant=branch start=2026-11-04T06:45:12.7131015Z peak_tree: vp.exe:24032 vp.exe:20572 vp.exe:38612 vp.exe:18908 node.exe:5536 cmd.exe:34068 node.exe:21020 | |
| cpus=4 run=5 variant=main start=2026-11-04T06:45:38.5158378Z peak_tree: vp.exe:55064 vp.exe:8444 vp.exe:38224 vp.exe:41828 node.exe:19336 cmd.exe:31480 node.exe:55944 | |
| cpus=4 run=5 variant=branch start=2026-11-04T06:46:12.7189893Z peak_tree: vp.exe:9512 vp.exe:39604 vp.exe:7436 vp.exe:25716 node.exe:20384 cmd.exe:37004 node.exe:27268 | |
| cpus=8 run=1 variant=main start=2026-11-04T06:47:35.0313481Z peak_tree: vp.exe:18868 vp.exe:12276 vp.exe:24368 vp.exe:32444 node.exe:44088 cmd.exe:5344 node.exe:30248 | |
| cpus=8 run=1 variant=branch start=2026-11-04T06:48:07.9363219Z peak_tree: vp.exe:24828 vp.exe:16252 vp.exe:51112 vp.exe:27192 node.exe:24232 cmd.exe:7988 node.exe:15528 | |
| cpus=8 run=2 variant=main start=2026-11-04T06:48:30.1282730Z peak_tree: vp.exe:42660 vp.exe:26684 vp.exe:28180 vp.exe:11888 node.exe:32608 cmd.exe:17172 node.exe:27272 | |
| cpus=8 run=2 variant=branch start=2026-11-04T06:49:04.0369118Z peak_tree: vp.exe:11980 vp.exe:43148 vp.exe:19260 vp.exe:47580 node.exe:17728 cmd.exe:6308 node.exe:45304 | |
| cpus=8 run=3 variant=main start=2026-11-04T06:49:27.0455541Z peak_tree: vp.exe:54536 vp.exe:35020 vp.exe:57104 vp.exe:25740 node.exe:23796 cmd.exe:33292 node.exe:53432 | |
| cpus=8 run=3 variant=branch start=2026-11-04T06:49:59.8271091Z peak_tree: vp.exe:19284 vp.exe:40392 vp.exe:19460 vp.exe:31936 node.exe:47128 cmd.exe:18492 node.exe:41004 | |
| cpus=8 run=4 variant=main start=2026-11-04T06:50:22.9666997Z peak_tree: vp.exe:54820 vp.exe:19092 vp.exe:48828 vp.exe:53584 node.exe:6280 cmd.exe:52568 node.exe:2340 | |
| cpus=8 run=4 variant=branch start=2026-11-04T06:50:58.6084152Z peak_tree: vp.exe:52596 vp.exe:23860 vp.exe:5136 vp.exe:17768 node.exe:19224 cmd.exe:42792 node.exe:49956 | |
| cpus=8 run=5 variant=main start=2026-11-04T06:51:22.2199601Z peak_tree: vp.exe:53972 vp.exe:20312 vp.exe:1808 vp.exe:55416 node.exe:38332 cmd.exe:37444 node.exe:5024 | |
| cpus=8 run=5 variant=branch start=2026-11-04T06:51:56.4457657Z peak_tree: vp.exe:32236 vp.exe:54632 vp.exe:47284 vp.exe:42320 node.exe:35920 cmd.exe:21444 node.exe:21284 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment