WorkstationsLatency and performancereference
Replacing a desktop utility with a zero-wakeup capture daemon
Long-lived desktop utilities accumulate features far faster than any single person uses them, and they often pay for that surface area with background threads, timers, and sustained memory working against the OS even when the tool is not active. Replacing one cleanly takes two separate disciplines: mining the incumbent tool’s own historical records so the replacement builds only the slice that actually runs, and designing the resident process around kernel blocking primitives so it records zero context switches while idle.
The reference implementation described here, snipx, replaced a ten-year ShareX 21.0.0 installation1 on a Windows 10 22H2 workstation (build 19045) tuned for an 8 kHz mouse (Fixing merged reports from an 8 kHz mouse on Windows). On that machine, periodic background wakeups from resident utilities show up directly as scheduling jitter and missed USB polling slots, the same constraint addressed when counting gaming APM without touching input latency. All measurements below were taken between 2026-10-21 and 2026-10-25 on that workstation unless labelled as design.
Mining the incumbent tool’s records
Section titled “Mining the incumbent tool’s records”Rewriting a utility from memory or from its settings screen guesses wrong in both directions: configured features that were tried once stay in scope, while daily interactions that bypass hotkeys get missed. A complete audit cross-checks four distinct records before any code is written.
Evidence sources and their blind spots
Section titled “Evidence sources and their blind spots”- Locate the live profile directory first. Long-installed desktop tools often redirect their data directory and leave a stale default folder behind. In ShareX,
PersonalPath.cfgredirected the active profile to an SMB network share whileDocuments\ShareXon the local drive still held a stale version 18 profile from 2025-09. Reading the local folder would have missed the last year of usage. - Copy the history database before opening it. The running desktop process holds
History.dbopen in SQLite; querying the live file in place risks locking conflicts or corrupting active writes. - Enumerate the upstream source tree to bound the candidate universe. Checking the ShareX
developtree (commitcc4fe6213d03) defined approximately 90 hotkey jobs (HotkeyType) and 23 post-capture pipeline steps (AfterCaptureTasks). Every candidate in that universe can then be marked with direct evidence rather than overlooked. - Mine the execution logs for invocation counts, then check what the logger omits. Parsing ten years of application logs (2016-2026) for
Executing:andHotkey triggered ... Job:lines gave exact invocation counts for the hotkey, tray, and menu actions present in its logs. Its blind spot is internal window navigation: the log never records opening the image history window or launching the annotation editor from inside that history view. Those surfaces only showed up by cross-checkingHistory.db(9,407 items recorded since 2022-09, and 31,166 total entries back to 2016 once monthly screenshot folders were backfilled) alongside the user’s workflow. - Read the live configuration last, strictly as a filter on parameters rather than proof of use. Configuration files (
HotkeysConfig.json,ApplicationConfig.json) show which options are armed on active paths, such asDetectControls: trueandQuickCropon the region picker, 2x image upscaling withen-GBon OCR, and the last-selected annotation settings (pixelate size 8, blur radius 15, 5 px red borders, arrows, outlined text, step numbers, highlight, and spotlight). They also contain dead weight: Dropbox, Pastebin, and Bitly accounts were configured in the profile with zero or single-digit executions across a decade.
Ten-year usage distribution and scope decisions
Section titled “Ten-year usage distribution and scope decisions”Across the 2016-2026 archive, capture volume averaged over 5,000 screenshots per year, running at 650 to 1,240 captures per month since 2026-02 (470 captures in the first three weeks of 2026-10 alone). Out of roughly 90 upstream jobs and 23 post-capture tasks, almost all real usage concentrated into five capture modes, two post-capture actions (copy image to clipboard and save PNG to <process>_YYYY-MM-DD_HH-MM-SS.png inside YYYY-MM folders), and two on-demand UI windows.
| Feature or job | Evidence across 2016-2026 records | Replacement decision |
|---|---|---|
Region capture (Alt+1, tray left click) | 31,607 logged executions (measured) | Rebuilt with window and child-control hover detection |
Active window capture (Alt+3) | 974 hotkey triggers + 20 menu runs (measured) | Rebuilt |
Fullscreen capture (Alt+2, tray middle click) | 889 logged executions (measured) | Rebuilt |
| S3-compatible object upload | 679 uploads in 2026-05-29..07-01; not bound to any hotkey (measured) | Dropped after credentials were retired; stubbed only |
Text capture / OCR (Alt+5) | 71 logged executions in 2021-2022 (measured) | Rebuilt with a local neural OCR engine ahead of Windows OCR |
| Tray double-click / history window | 30 logged tray opens; 9,407 History.db rows since 2022-09 (measured) | Rebuilt as a separate short-lived GUI binary |
Screen recording (Alt+4) | 24 starts; 28 MP4 files (12 in 2025-26), 4 custom regions, 3 GIFs (measured) | Rebuilt natively via Media Foundation H.264 (60 fps) and GIF (30 fps) |
| Image annotation editor | 9 direct log runs + launches from inside the history window (measured) | Rebuilt in the separate GUI binary using non-destructive JSON sidecars |
Scrolling capture (Alt+6) | 0 log entries; added by explicit request on 2026-10-23 | Built with an app-agnostic luma-difference frame stitcher |
| Dropbox, Imgur, and file upload jobs | 7 Dropbox, 1 Imgur, 1 file upload in 10 years (measured) | Deliberately omitted |
| Remaining ~80 jobs (colour picker, ruler, pin, QR, hashes, combiner, effects, watermarks, timers, URL shorteners, video tools) | 0 log entries in 10 years (measured) | Deliberately omitted |
Upgrading weak components discovered during the audit
Section titled “Upgrading weak components discovered during the audit”Log mining also exposes features that were abandoned because the incumbent implementation worked poorly. Only 71 OCR captures appeared in the logs because Windows.Media.Ocr (which ShareX calls through OCRHelper.cs) routinely returned empty strings on small, low-contrast grey UI text over dark backgrounds.
Testing a synthetic corpus of 16 lines rendered in Segoe UI and Consolas (grey on near-black at normal size and shrunk to 75 % for 7-8 px text, upscaled 3x with Lanczos) quantified the gap on 2026-10-23 without sending real screenshots to third-party APIs:
| OCR engine | Small text accuracy | Tiny (7-8 px) accuracy | Median latency |
|---|---|---|---|
Windows.Media.Ocr (single pass) | 0.824 (measured) | 0.190 (measured) | local |
Windows.Media.Ocr (with 4-rung preprocessing ladder, 2026-10-24) | 0.894 (measured) | 0.373 (measured) | local |
Tesseract (Linux, psm 6) | 0.985 (measured) | 0.838 (measured) | 0.2 s |
ocrs 0.13 (pure Rust CPU inference, .rten models) | 0.973 single / 0.966 ladder (measured) | 0.900 single / 0.906 ladder (measured) | 0.2 s |
| Open-weight vision models (Qwen3-VL 8B/30B/235B, Gemma 4, Ministral 3B/8B) | 0.998-1.000 (measured) | 0.991-1.000 (measured) | 0.7-4.4 s |
Adding a 3x Lanczos upscaling and four-rung contrast and threshold preprocessing ladder caused Windows.Media.Ocr to emit non-empty garbage on tiny text (0.373 character accuracy) instead of an empty string. Because an OCR fallback chain advances on empty output, an unavailable engine, or an error - the first non-empty result wins - the pure-Rust ocrs engine had to be placed first in the chain (["ocrs", "windows"] on Windows, ["ocrs", "tesseract"] on Linux), with an optional vision-model HTTP endpoint behind it. During the bake-off, sending 16-bit greyscale PNGs to vision APIs caused every remote model to report a blank image; encoding OCR crops as 8-bit RGB fixed the failure.
Measuring resident idle cost
Section titled “Measuring resident idle cost”A resident tray utility spends almost all its wall-clock life waiting for a hotkey. To verify that a replacement records zero context switches during that wait, the measurement gate must count kernel context switches per thread rather than coarse process CPU percentages.
Per-thread context-switch gate
Section titled “Per-thread context-switch gate”On Windows, the gate script queries Win32_PerfRawData_PerfProc_Thread via CIM before and after a 60-second hands-off window, keying each thread’s raw ContextSwitchesPersec counter by IDProcess/IDThread:
param( [Parameter(Mandatory = $true)][string]$Name, [int]$Seconds = 60, [int]$MaxSwitchesPerMin = 0)
$ErrorActionPreference = 'Stop'$procs = @(Get-Process -Name $Name -ErrorAction SilentlyContinue)if ($procs.Count -eq 0) { exit 2 }$pids = $procs | ForEach-Object { $_.Id }
function Get-Switches { $h = @{} Get-CimInstance Win32_PerfRawData_PerfProc_Thread | Where-Object { $pids -contains [int]$_.IDProcess } | ForEach-Object { $h["$($_.IDProcess)/$($_.IDThread)"] = [int64]$_.ContextSwitchesPersec } return $h}function Get-Cpu { ($pids | ForEach-Object { (Get-Process -Id $_).TotalProcessorTime.TotalMilliseconds } | Measure-Object -Sum).Sum}
$s0 = Get-Switches; $c0 = Get-CpuStart-Sleep -Seconds $Seconds$s1 = Get-Switches; $c1 = Get-Cpu
$delta = [int64]0; $threadsSeen = 0foreach ($k in $s1.Keys) { if ($s0.ContainsKey($k)) { $delta += $s1[$k] - $s0[$k] $threadsSeen++ }}$perMin = [math]::Round($delta * 60.0 / $Seconds, 1)$cpuMs = [math]::Round($c1 - $c0, 1)Summing raw counters per thread and intersecting s0 and s1 avoids a subtle measurement bug: when a short-lived thread exits midway through the sampling window, its counter disappears from the process table, which drives a process-wide sum negative. On Linux, the equivalent gate sums voluntary_ctxt_switches and nonvoluntary_ctxt_switches across /proc/<pid>/task/*/status before and after sleep 60.
The idle budget requires the gate to run under two conditions: mouse stationary and mouse moving at 8 kHz. A process that installs a low-level mouse hook (WH_MOUSE_LL) or a background raw-input listener (RIDEV_INPUTSINK) can look quiet while the cursor is still and then wake thousands of times per second once the cursor moves23.
Baseline and A/B measurements
Section titled “Baseline and A/B measurements”| Process and condition (Windows 10 22H2, 60 s window) | Context switches / min | Threads | Working set | Private bytes | CPU time / 60 s |
|---|---|---|---|---|---|
waitfor.exe (OS blocking control, 2026-10-21) | 0 (measured) | 1 | - | - | 0 ms |
| ShareX 21.0.0 idle baseline (2026-10-21) | ~10,800 (measured; 3 threads at ~102/s, ~68/s, ~17/s) | 34 | 155 MiB | - | - |
| ShareX 21.0.0 resident A/B (2026-10-24) | 12,837 (measured) | 34 | 159 MiB | 112 MiB | 141 ms |
| Replacement daemon at idle, fresh start (2026-10-21 & 2026-10-24) | 0 (measured) | 1 | 7.0-8.1 MiB | 1.3-1.5 MiB | 0 ms |
| Replacement daemon after capture, before IME fix (2026-10-24) | ~4 (measured; TppWorkerThread wakeups) | 6 | 39.0 MiB | 4.3 MiB | 0 ms |
Replacement daemon after capture, with ImmDisableIME(0), clipboard emptied (2026-10-25) | 0 (measured) | 1 | 7.0 MiB | 1.4 MiB | 0 ms |
Active capture latency
Section titled “Active capture latency”While idle cost is governed by context switches, active capture quality depends on hotkey-to-clipboard latency. Instrumenting each stage of a 2560x1440 fullscreen capture on 2026-10-23 showed that PNG encoding dominated total wall time when using the png crate’s Compression::Balanced setting:
| Stage (2560x1440 capture, milliseconds) | With Compression::Balanced | With Compression::Fast |
|---|---|---|
GDI BitBlt screen grab | 26.5 (measured) | 26.5 (measured) |
| PNG encode (BGRA to RGB deflate) | 408-574 ms, 1.74 MB output (measured) | 22-26 ms standalone / 42.0 in daemon pipeline, 2.26 MB output (measured) |
Atomic file save (create_new reservation) | 2.3 (measured) | 2.3 (measured) |
Clipboard write (CF_DIB + "PNG") | 20.4 ms (measured) | 20.4 ms (measured) |
| Total hotkey to saved + clipboard | ~470-600 ms (measured) | 94.3 ms (measured) |
Switching to Compression::Fast cut deflate time by roughly 20x and brought the end-to-end hotkey response to 94.3 ms, trading 0.52 MB of extra disk space per screenshot (about 240 MB per month at 470 captures/month).
Zero-wakeup daemon architecture on Windows
Section titled “Zero-wakeup daemon architecture on Windows”Keeping a resident daemon at zero context switches per minute and ~1.4 MiB of steady-state private memory requires stripping out every runtime subsystem that polls, spawns background worker pools, or holds freed heap pages.
Three-binary process split and LTO dead-code stripping
Section titled “Three-binary process split and LTO dead-code stripping”A single binary that links a GUI toolkit, a neural OCR runtime, and an HTTP client pays for their static initialisers, TLS tables, and binary size in the resident process. Splitting the build into three executables isolates the resident footprint:
- The resident daemon binary compiles with
#![cfg_attr(windows, windows_subsystem = "windows")]so Windows autostart opens no console window, and links no GUI toolkit, async runtime, or ML engine. - The console CLI binary exposes the command-line interface and registers the in-process OCR engine chain at startup via a
OnceLock<fn(&Frame) -> Result<Outcome>>hook (ocr::enable_in_process_chain()). Because the daemon binary never calls that registration function, compiling the release profile withlto = trueandcodegen-units = 1allows the linker to dead-code-stripocrs,rten, andureqout of the daemon executable. A runtime check oncurrent_exe()would leave those crates reachable in the call graph; theOnceLocksplit keeps the resident daemon binary at 0.75 MB instead of 6.3 MB. - The history browser and annotation editor live in a separate workspace crate (
egui/eframe) compiled into a third binary that runs only while the window is open on screen.
When the user presses the OCR hotkey (Alt+5), the daemon captures and saves the cropped PNG on its short-lived action thread, then invokes the sibling CLI binary (<exe_dir>/... ocr <png>) via CreateProcessW with CREATE_NO_WINDOW and a 30-second WaitForSingleObject timeout. The parent creates two anonymous pipes (CreatePipe) with bInheritHandle = 1 and immediately strips HANDLE_FLAG_INHERIT from its own read handles via SetHandleInformation; otherwise the child inherits the read end of its own pipe and the parent’s reader never sees EOF.
When launching the GUI binary for image history or editing, standard library std::process::Command is unsuitable on Windows because it calls CreateProcessW with bInheritHandles = TRUE. That flag leaks every inheritable handle of the parent into the long-lived GUI process, including any stdout pipe held by a calling script, CI runner, or WSL interop session, causing the caller to hang until the user closes the GUI window. Calling CreateProcessW directly with bInheritHandles = 0 (FALSE) and CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT, then closing hProcess and hThread immediately, detaches the GUI cleanly.
Blocking message loop and bounded timer exceptions
Section titled “Blocking message loop and bounded timer exceptions”At startup, the daemon creates a per-session named mutex (CreateMutexW in the Local\ namespace) to enforce a single instance, creates an unshown WS_OVERLAPPED top-level window (using a real top-level window rather than HWND_MESSAGE so the CLI’s stop command can locate it with FindWindowW and post WM_CLOSE), registers the TaskbarCreated broadcast message so the tray icon survives explorer.exe restarts, adds its tray icon via Shell_NotifyIconW, and registers each hotkey with RegisterHotKey using MOD_NOREPEAT4.
The main thread then enters an unconditional kernel wait5:
let mut msg = MSG::default();let got = loop { let r = unsafe { GetMessageW(&mut msg, std::ptr::null_mut(), 0, 0) }; if r <= 0 { break r; // 0 = WM_QUIT; -1 = Win32 error } unsafe { DispatchMessageW(&msg) };};No periodic timers exist at idle:
- Tray single-click versus double-click: left-clicking the tray icon starts a region capture, while double-clicking opens the image history window. So that the first click of a double-click does not also fire a region capture,
WM_LBUTTONUParms a one-shotSetTimerforGetDoubleClickTime()milliseconds. IfWM_LBUTTONDBLCLKarrives before the interval expires, it callsKillTimerand launches the history binary; if the timer expires first, theWM_TIMERhandler immediately callsKillTimeron itself and starts the region capture. The timer lives for a few hundred milliseconds after a human click and never repeats. - Notification rate limiting: because a GUI-subsystem process has no stderr, capture warnings and OCR errors surface as tray balloons (
Shell_NotifyIconWwithNIM_MODIFY | NIF_INFO). To prevent a burst of hotkey presses from stacking balloons, aBalloonGatechecksstd::time::Instant::now()on the action thread and suppresses notifications within 3 seconds of the previous one, requiring no background timer. - Daemon logging: each log line opens the log file under
%LOCALAPPDATA%withOpenOptions::new().create(true).append(true), writes the line, and closes the handle immediately, avoiding any background flush thread. - Screen recording elapsed clock: a 1 Hz timer updates the recording border toolbar’s
mm:sscounter only while an active recording is running, and both the border ring and toolbar setWDA_EXCLUDEFROMCAPTUREso the compositor omits them from the recorded video.
Synchronous overlay painting under 8 kHz mouse traffic
Section titled “Synchronous overlay painting under 8 kHz mouse traffic”The daemon registers no mouse hook and no raw-input sink while idle. When a region capture starts, a short-lived thread freezes the virtual screen via GDI BitBlt and opens a topmost popup overlay (WS_POPUP | WS_EX_TOPMOST | WS_EX_TOOLWINDOW) that receives standard WM_MOUSEMOVE messages while the user drags a selection rectangle.
In the Win32 message queue, WM_PAINT has the lowest dispatch priority: GetMessageW delivers all queued input messages (WM_MOUSEMOVE) before synthesizing a WM_PAINT5. With a mouse polling at 8,000 Hz, a WM_MOUSEMOVE is almost always pending, starving deferred repaints so the selection box freezes until the hand pauses. To keep the overlay responsive at 8 kHz, each motion step computes the minimal dirty region (CombineRgn with RGN_XOR between the old and new selection rectangles), composites into an off-screen GDI DIB section clipped to that region (SelectClipRgn), and calls InvalidateRgn followed immediately by UpdateWindow(hwnd) to dispatch WM_PAINT synchronously before returning from the input message.
Preventing Windows IME thread-pool workers from spawning
Section titled “Preventing Windows IME thread-pool workers from spawning”Even with an unconditional GetMessageW loop and a short-lived thread per hotkey, the 2026-10-24 resident profile after a single region capture (Alt+1) showed the daemon retaining 3 to 5 extra threads sitting in EventPairLow waits (ntdll!TppWorkerThread). Two of those kernel thread-pool workers woke twice per minute each, producing roughly 4 context switches per minute and violating the zero-wakeup budget.
To find which Win32 call spawned the default process thread pool, an offline probe (tests/probe.rs) executed each stage of the capture pipeline in its own fresh process (screen grab, PNG encode, local file write, UNC path write, clipboard write, overlay window creation/destruction, tray notification, and history append) and inspected the process’s thread array via NtQuerySystemInformation(SystemProcessInformation) (walking the 256-byte SYSTEM_PROCESS_INFORMATION header and 80-byte SYSTEM_THREAD_INFORMATION entries with context_switches at byte offset 64) immediately after the call and after 30 seconds of idle sleep.
The probe isolated the cause to step (f): creating the first top-level Win32 window on a fresh thread causes the Windows Input Method Editor and Text Services Framework (IME/TSF) to attach to that thread, which initializes the process’s default TppWorkerThread pool. Once created, the default Windows thread pool stays in the process for its lifetime.
Calling ImmDisableIME(0) on each hotkey thread before it creates its first window (both in the region selector overlay and on the recording border thread) prevents IME/TSF from attaching6:
pub fn select_region(frame: &Frame, screen: Rect, t0: Instant) -> Result<Rect> { // Prevent IME/TSF from attaching to this fresh hotkey thread and leaving // permanent ntdll!TppWorkerThread workers in the resident daemon. unsafe { windows_sys::Win32::UI::Input::Ime::ImmDisableIME(0) }; // ...Re-running the 60-second idle gate on the CI-built daemon after a full Alt+1 region capture confirmed that the process returned to 1 thread and 0 context switches per minute.
Returning post-capture memory to the OS
Section titled “Returning post-capture memory to the OS”A 2560x1440 BGRA capture frame occupies 14,745,600 bytes (14.06 MiB). On the initial daemon build, taking a single fullscreen screenshot raised the daemon’s working set from 7.0 MiB to 35.8 MiB and its private bytes from 1.3 MiB to 16.1 MiB, where it remained across ten subsequent captures. Two distinct Windows memory mechanisms were holding those pages committed:
- NT heap retention of large buffers: when Rust’s default
Systemallocator frees a 14.06 MiBVec<u8>back to the Windows process heap (HeapFree), the NT heap keeps those virtual pages committed in the process rather than unmapping them, and callingHeapCompact(GetProcessHeap(), 0)after the capture did not decommit them. The daemon binary overrides#[global_allocator]with a size-split allocator (BigAlloc) that routes any layout of at least 1 MiB (BIG_THRESHOLD = 1 << 20, rounded up to 4 KiB pages) directly toVirtualAlloc(..., MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE)and releases it on drop viaVirtualFree(ptr, 0, MEM_RELEASE)7:
const BIG_THRESHOLD: usize = 1 << 20;const PAGE: usize = 1 << 12;
unsafe impl GlobalAlloc for BigAlloc { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { if layout.size() < BIG_THRESHOLD { return unsafe { System.alloc(layout) }; } let size = layout.size().next_multiple_of(PAGE); unsafe { VirtualAlloc( std::ptr::null(), size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE, ) .cast() } }
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { if layout.size() >= BIG_THRESHOLD { unsafe { VirtualFree(ptr.cast(), 0, MEM_RELEASE) }; } else { unsafe { System.dealloc(ptr, layout) }; } }}Because Rust’s GlobalAlloc trait passes the exact same Layout (size and align) to dealloc that was given to alloc, and VirtualAlloc’s 64 KiB allocation granularity covers any alignment the allocator contract allows, this routing requires no side-table or lock. The 1 MiB threshold ensures that any allocation at or above 1 MiB - the full-screen Fast PNG at 2.26 MB and the raw frame at 14.06 MiB - routes through VirtualAlloc and is unmapped immediately on drop.
- Clipboard global handles and
WM_DESTROYCLIPBOARD: while the captured screenshot sits on the Windows clipboard, theGMEM_MOVEABLEglobal memory blocks forCF_DIB(14.75 MB at 2560x1440) and"PNG"(1.7-2.3 MB depending on compression) are charged to the clipboard-owning process’s private bytes (~16-18 MiB total). Win32 delayed clipboard rendering (SetClipboardData(CF_DIB, NULL)) does not avoid this charge on a workstation running WSLg, becausemsrdc.exe(the WSLg RDP clipboard bridge) requestsCF_DIBwithin milliseconds of every capture. Instead, the daemon registers its hiddenhwndas the clipboard owner inOpenClipboard(owner). The moment any other application copies to the clipboard (or the next capture empties it), Windows sendsWM_DESTROYCLIPBOARDto the daemon’swndproc8, which runsHeapCompact(GetProcessHeap(), 0)once on that event and drops the daemon’s private bytes back to ~1.4 MiB without a background timer.
App-agnostic scrolling capture and sidecar annotations
Section titled “App-agnostic scrolling capture and sidecar annotations”Two interactive features that survived the scope audit needed specific designs to stay self-contained without browser extensions or destructive file edits:
- App-agnostic scrolling stitcher (
Alt+6): exact row-hash matching fails on modern desktop applications because floating toolbars and scroll indicators alter roughly 6 % of rows between wheel steps. Instead, the stitcher computes the vertical shift that minimises a trimmed mean luma difference across moving columns, scored only on rows that are unique within their frame, and drops narrow moving edge strips caused by fading overlay scrollbar thumbs. Static viewport rows (sticky headers or footers) are repaired from frames where the underlying content row was unobstructed. After each synthetic mouse-wheel event, a settle loop waits for motion to begin and then waits for two consecutive grabs to match before advancing. Each step is capped at half the viewport height (3/4 height was tested and mis-stitched animated in-page regions), and the capture stops after two unchanged steps or at 400 steps / 1 GiB (stitched images above 100 MB are saved to disk without copying to the clipboard). On a 2026-10-25 run that produced a 61,280 px tall image, the median step took 528 ms, of which 462 ms was spent waiting for the target application’s smooth-scroll animation to settle. - Non-destructive editor sidecars: opening the annotation editor from the history window never overwrites the original screenshot. Saving (
Ctrl+S) writes a JSON recipe sidecar beside the capture containing the schema version, source fingerprint, vector shapes (rectangles, arrows, outlined text, step numbers, highlight, spotlight, pixelate, blur, and solid-box redaction), and crop bounds, while exporting (Ctrl+E) renders<stem>-edit.png.
Cross-compilation and CI-only deployment
Section titled “Cross-compilation and CI-only deployment”Developing a Windows system-tray daemon from a Linux or WSL2 environment is fastest when the compiler runs natively on Linux while tests and binaries execute in the interactive Windows desktop session through WSL interop:
- Cross-compilation via
cargo-xwin:cargo xwin build --target x86_64-pc-windows-msvcdrives the host’sclang-clandlld-linkagainst cached MSVC CRT and Windows SDK headers, andllvm-rccompiles the.rcicon andVERSIONINFOresources. - Native OS TLS on Windows: in
Cargo.toml, the HTTP client (ureq) selectsrustlson Linux (cfg(not(windows))) but switches tonative-tls(Windows Schannel and the OS root certificate store) oncfg(windows). Usingrustlson Windows pulls inring, whose C build script requires a full Windows C compiler setup inside the Linux CI container. - Automated Windows test runner: setting
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUNNERto a wrapper script allowscargo xwin testto stage each compiled.exetest binary into%TEMP%on the Windows host, invoke it through WSL interop against the real Win32 desktop APIs, and clean up the temporary directory on exit.
For the live workstation installation, a strict provenance rule (adopted 2026-10-25) forbids deploying locally compiled binaries or citing them as final verification. Every executable installed to %LOCALAPPDATA%\Programs\... or used for acceptance gates is fetched from the CI pipeline artifact for that pushed git commit:
- The CI workflow cross-builds the workspace using a version- and SHA-256-pinned
cargo-xwin, emitsBUILD.txtandSHA256SUMS, and embeds the git commit hash and CI run number into the binary at build time soversionprints(<commit> ci#<run>)for CI artifacts and(local build)for developer builds. - The deploy script resolves the latest green CI run for
HEAD, downloads the artifact zip, verifiessha256sum --quiet -c SHA256SUMS, checks that the detached GUI process is not currently open (which would lock the executable on Windows and risk losing unsaved editor sidecars), stops the running daemon viaWM_CLOSE, copies the verified executables into place, restarts the daemon, and checksversionoutput to confirm the live binary carries aci#<run>stamp. - Local builds (
make windev) write exclusively to isolated scratch directories under%TEMP%or%USERPROFILE%with overridden save-directory, data-directory, and config-path environment variables so parallel test runs never touch the live daemon, screenshot archive, or history file.
Verification summary
Section titled “Verification summary”| Claim | How it was checked | Status |
|---|---|---|
| 10-year usage distribution across ~90 ShareX jobs and 23 post-capture tasks | Log parser over 2016-2026 ShareX logs + History.db + cc4fe6213d03 enums (2026-10-23) | Measured |
ocrs 0.13 vs Windows.Media.Ocr on 7-8 px dark-mode UI text (0.900/0.906 vs 0.190/0.373) | 16-line synthetic Segoe UI / Consolas corpus at 100 % and 75 % scale (2026-10-23 & 2026-10-24) | Measured |
| ShareX 21.0.0 costs 10.8k-12.8k context switches/min and 155-159 MiB WS at idle | 60 s Win32_PerfRawData_PerfProc_Thread delta on Windows 10 22H2 (2026-10-21 & 2026-10-24) | Measured |
| Replacement daemon holds 0 context switches/min, 1 thread, ~1.4 MiB private bytes at idle and after captures | 60 s per-thread counter gate + NtQuerySystemInformation per-step isolation probe (2026-10-25) | Measured |
Compression::Fast cuts 2560x1440 PNG encode from 408-574 ms to 22-26 ms (94.3 ms total hotkey latency) | Per-stage Instant instrumentation across 5 runs at 2560x1440 (2026-10-23) | Measured |
LTO strips ocrs + rten + ureq from the daemon when OnceLock hook is uncalled (0.75 MB vs 6.3 MB) | Release binary size comparison on x86_64-pc-windows-msvc (2026-10-24) | Measured |
Linux X11 daemon and capture backend (XGrabKey, GetImage) | Automated tests and 60 s idle gate under rootful Xvfb | Tested in CI/Xvfb |
| Linux Wayland capture and portal hotkey backend | Stubbed module (NotImplemented) | Design only |
Related docs
Section titled “Related docs”- Counting gaming APM without touching input latency covers the companion resident utility on the same Windows 10 workstation and shows why
WH_MOUSE_LLhooks andRIDEV_INPUTSINKraw-input listeners degrade 8 kHz mouse report delivery. - Fixing merged reports from an 8 kHz mouse on Windows details the USB controller topology, interrupt affinity, and idle-state tuning that make background process wakeups visible as mouse polling spikes.
- GPU HDMI audio vs a USB DAC measures audio output latency on the same Windows 10 22H2 desktop and documents the WSL interop gotchas encountered when running Windows measurement scripts from Linux.
- Building Windows releases on a Linux-only Forgejo runner shows the VM-based alternative for Windows builds when a toolchain cannot be cross-compiled from Linux with
cargo-xwin.
References
Section titled “References”-
Microsoft, “LowLevelMouseProc callback function,” Microsoft Learn. https://learn.microsoft.com/en-us/windows/win32/winmsg/lowlevelmouseproc ↩
-
BoosterX, “Background Raw Input listeners in Windows 10 and Windows 11,” BoosterX Wiki. https://wiki.boosterx.org/en/windows-research/input/background-raw-input-throttling/ ↩
-
Microsoft, “RegisterHotKey function (winuser.h),” Microsoft Learn. https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerhotkey ↩
-
Microsoft, “GetMessageW function (winuser.h),” Microsoft Learn. https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessagew ↩ ↩2
-
Microsoft, “ImmDisableIME function (imm.h),” Microsoft Learn. https://learn.microsoft.com/en-us/windows/win32/api/imm/nf-imm-immdisableime ↩
-
Microsoft, “VirtualAlloc function (memoryapi.h),” Microsoft Learn. https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualalloc ↩
-
Microsoft, “WM_DESTROYCLIPBOARD message (Winuser.h),” Microsoft Learn. https://learn.microsoft.com/en-us/windows/win32/dataxchg/wm-destroyclipboard ↩