Repository navigation
Conversation
tzarebczan
added a commit
that referenced
this pull request
Sep 26, 2026
Walk Unix folders with dua-core instead of jwalk: 3–6× faster scans with less CPU
huntharo
force-pushed
the
feat/diagnostics-profiler
branch
4 times, most recently
from
October 1, 2026 18:53
a162963 to
520c10c
Compare
huntharo
force-pushed
the
feat/diagnostics-profiler
branch
from
October 14, 2026 19:05
520c10c to
da2e991
Compare
crash.log is buffered now. The near-limit breadcrumb, and a new line before each heap snapshot, append before returning, since the process can die before the next flush. The I/O budgets log through the real buffered crash.log. DiagnosticsManager.stop() waits for a heap capture that already started, and a tick that was reading the gate's day state when stop() ran no longer fires the gate.
vi.waitUntil advances fake time on every check while it waits, so a slow CI disk moved the second capture relative to the cooldown, or timed the wait out. The tests now wait for onProfileWritten and move fake time only where they say so. With writes delayed 400 ms, the old tests fail as macOS CI did and the new ones pass.
huntharo
force-pushed
the
feat/diagnostics-profiler
branch
from
October 22, 2026 01:52
da2e991 to
b87408e
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
Opt-in diagnostics for DiskHound's main process, for bug reports about a hot or bloated main thread. Everything lands under
<userData>/diagnostics/, one folder per session:session.json,samples.ndjson,events.ndjsonand the captures.hot-cpu-profiler.ts:joinCpuProfiles, so a.cpuprofilereaches 30–60 s before the trigger.process.threadCpuUsage(), the main thread only. Busy scan and folder-tree workers don't fire it, and heap snapshots are discounted..heapprofile.heap-gate-state.json.worker.getHeapStatistics()through a small registry every worker runtime now uses. They are shown in status and used by the near-limit diagnostic breadcrumb.[memory]line gains acage:summary.DISKHOUND_HOT_CPU_PROFILING=1|0(plus_THRESHOLD_PERCENT,_WINDOW_MS, …),DISKHOUND_HEAP_GATE_MB,DISKHOUND_HEAP_SNAPSHOTS=1and others (seediagnosticsConfig.ts). Active overrides show in Settings, in the handoff text and in crash.log.Snapshot behavior and prior measurements
Manual and enabled automatic captures call V8 without a fixed heap ceiling or estimated free-heap admission check, matching PwrAgnt/PwrGit. The daily capture limit and cancellation when snapshots are disabled remain in place. Full snapshots pause main and can consume substantial memory and disk space.
The earlier measurements below used Electron 40.6's Node (24.13.1) via
ELECTRON_RUN_AS_NODE=1 --expose-gc, with a reported 4096 MB heap limit. This was a synthetic Map of path strings to{size, files, children, mtime}records, not the normal app launch configuration; its failures do not establish a universal Electron heap-size limit.EXC_BREAKPOINTinsidev8::HeapProfiler::TakeHeapSnapshot, with no crash.log line and exit code 133.Sampling runs from launch, not from a watch mark
The heap profiler was going to start at 75% of the gate. In the real app, a scan took the main heap from 30 to 83 MB within one 5 s check, and the gate's profile came out empty. A folder-tree load grows the heap the same way.
DISKHOUND_HEAP_WATCH_MBcan still set a watch mark.Disk writes
All defaults are off. Budgets are in
src/test/io-budgets.json, recorded byhotCpuProfiler.ioBudget.test.tsandheapMonitor.ioBudget.test.ts. Reads and samples stay in memory; nothing is written per tick.heap-gate-state.jsonper launchThe CPU profiler's idle cost is main-thread CPU of 0.92% with it on and 0.07% with it off. That is about 0.85% of a core, in the app with nothing happening.
Verification
e2e/diagnostics.spec.ts. It passes locally on macOS; CI runs it on Linux, Windows and macOS..cpuprofilethat contains it, with more than 3 s of lookback..heapprofilethat attributes more than 50 MB to the allocating function.launch({ env })and adiagnosticssettings seed.main-hot-0001.cpuprofile, 638 KB, "73 s, 58 s before a 88% main-thread trigger". The 58,645 samples have no gaps at the join.DISKHOUND_HEAP_GATE_MB=100with snapshots, during a 624k-file scan of~/github..heapprofile(162 KB, "sampled for 20 s from 15 MB") is led byparseFolderTreeSidecarLine,readTripleArrayandloadFolderTreeSidecar.../../etcand unknown names. Delete all keepsheap-gate-state.json, so the daily cap survives a clear.bun run typecheck && bun run test && bun run buildpasses, and all 19 E2E tests pass locally.Screenshots
Paths in the screenshots are shown as the default macOS userData folder; they were taken on a scratch profile.
Settings → Diagnostics, defaults:
Everything on, after the captures above, at the default 1.2 GB gate:
The gate's snapshot A in DevTools → Memory: