Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
158 lines (148 loc) · 41.6 KB
/
Copy pathindex.html
File metadata and controls
158 lines (148 loc) · 41.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#f2f0e9">
<title>Inside duscape | Systems, scanners, and speed</title>
<link rel="icon" href="../../viewers/windows/duscape.ico" sizes="16x16 20x20 24x24 32x32 48x48 256x256" type="image/x-icon">
<link rel="stylesheet" href="./explainer.css">
<script type="module" src="./explainer.js"></script>
</head>
<body>
<header class="topbar">
<a class="wordmark" href="#top" aria-label="Duscape internals home"><img class="brand-icon" src="../../viewers/windows/duscape.ico" alt=""> duscape <span class="wordmark-note">FIELD GUIDE / 01</span></a>
<nav aria-label="Page sections">
<a href="#system">System</a><a href="#scanners">Scanners</a><a href="#viewers">Viewers</a><a href="#evidence">Evidence</a><a href="#frames">Frames</a>
</nav>
</header>
<main id="top">
<section class="hero page-width">
<div class="hero-copy">
<p class="eyebrow"><span class="eyebrow-dot"></span> An interactive systems tour</p>
<h1>Make the disk wait.<br><em>Never the person.</em></h1>
<p class="hero-intro">Duscape turns a live filesystem walk into a useful picture without making the window wait for the disk, the tree, or a preview to finish.</p>
<a class="text-link" href="#system">Follow one scan <span aria-hidden="true">↓</span></a>
</div>
<div class="hero-art" aria-label="A treemap sketch composed of colored tiles">
<div class="art-label">ONE WALK<br>MANY VIEWS</div><div class="tile tile-a"><span>src</span></div><div class="tile tile-b"><span>assets</span></div><div class="tile tile-c"><span>cache</span></div><div class="tile tile-d"><span>large file</span></div><div class="tile tile-e"></div><div class="tile tile-f"></div><div class="art-index">FIG 01 <span>·</span> THE SHARED MODEL</div>
</div>
<div class="hero-foot"><span>Rust · platform-native I/O · shared accounting</span><span>Architecture, with the measurements left in</span></div>
</section>
<section class="section system-section" id="system">
<div class="page-width">
<div class="section-heading"><div><p class="eyebrow">01 / The shape of the work</p><h2>One pipeline, separate clocks.</h2></div><p class="section-deck">The scanner owns slow I/O. Builders own private trees. The viewer thread owns interaction and paint. Bounded messages let each side make progress without handing a million-entry backlog to the screen.</p></div>
<div class="explorer-shell">
<div class="explorer-controls">
<div class="control-group" role="group" aria-label="Choose a platform route"><span class="control-label">TRACE A ROUTE</span><button class="seg-button is-active" data-platform="linux" aria-pressed="true">Linux</button><button class="seg-button" data-platform="macos" aria-pressed="false">macOS</button><button class="seg-button" data-platform="windows" aria-pressed="false">Windows</button></div>
<div class="control-group focus-controls" role="group" aria-label="Emphasize a pipeline layer"><button class="focus-button is-active" data-focus="all" aria-pressed="true">Whole system</button><button class="focus-button" data-focus="scan" aria-pressed="false">Scanner</button><button class="focus-button" data-focus="view" aria-pressed="false">Viewer</button></div>
</div>
<div class="route-caption" aria-live="polite"><span class="route-index" id="routeIndex">ROUTE / LINUX</span><p id="routeSummary">getdents64 + statx, in parallel; optionally read ext4 metadata from the device as root.</p><button class="run-button" id="runTrace" type="button"><span class="play-icon" aria-hidden="true">▶</span> Run the trace</button></div>
<div class="pipeline" id="pipeline" data-focus="all" aria-label="Scan pipeline diagram">
<div class="flow-node scan-node" data-layer="scan"><span class="node-kicker">01 / WALK</span><strong id="scannerNode">Linux walker</strong><small id="scannerNodeNote">directory batches from getdents64 + statx</small><span class="worker-badge" id="walkerWorkers">WORKER POOL · 3/CORE, MAX 32</span><div class="worker-bank worker-bank-walk" aria-hidden="true"><span class="worker-box">W1</span><span class="worker-box">W2</span><span class="worker-box">W3</span></div></div><div class="flow-link" aria-label="C: shared bounded message channel"><span class="flow-packet"></span><span class="channel-queue" aria-hidden="true"><i></i><i></i><i></i></span><span class="bound-marker">C</span></div>
<div class="flow-node protocol-node" data-layer="scan"><span class="node-kicker">02 / SCAN FAN-OUT</span><strong>DirEntries</strong><small>each directory feeds two paths</small><div class="fanout-branches"><div class="fanout-branch fanout-live"><span>OUTLINE</span><strong>→ UI now</strong><small>depth-capped summaries</small><b class="principle-badge principle-a">A · COARSE NOW</b></div><div class="fanout-branch fanout-build"><span>BUILD BATCHES</span><strong>→ shard queues</strong><small>full directory entries</small></div></div></div><div class="flow-link" aria-label="C: shared bounded message channel"><span class="flow-packet"></span><span class="channel-queue" aria-hidden="true"><i></i><i></i><i></i></span><span class="bound-marker">C</span></div>
<div class="flow-node build-node" data-layer="model"><span class="node-kicker">03 / BUILD</span><strong>Private trees</strong><small>one FileTree per shard</small><span class="worker-badge" id="builderWorkers">BUILDERS · 4 SHARDS</span><div class="worker-bank worker-bank-builders" id="builderBank" aria-hidden="true"><span class="worker-box" data-builder="1">B1</span><span class="worker-box" data-builder="2">B2</span><span class="worker-box" data-builder="3">B3</span><span class="worker-box" data-builder="4">B4</span></div></div><div class="flow-link" aria-label="C: shared bounded message channel"><span class="flow-packet"></span><span class="channel-queue" aria-hidden="true"><i></i><i></i><i></i></span><span class="bound-marker">C</span></div>
<div class="flow-node model-node" data-layer="model"><span class="node-kicker">04 / FINISH</span><strong>Merge + replay</strong><small>reconcile shared-block ledger</small><span class="principle-badge principle-b">B · COMPLETE AFTER</span><div class="worker-bank worker-bank-serial" aria-label="One serial merge worker"><span class="worker-box">MERGE</span></div></div><div class="flow-link" aria-label="C: shared bounded message channel"><span class="flow-packet"></span><span class="channel-queue" aria-hidden="true"><i></i><i></i><i></i></span><span class="bound-marker">C</span></div>
<div class="flow-node view-node" data-layer="view"><span class="node-kicker">05 / INTERACT + PAINT</span><strong id="viewerNode">Linux window / TUI</strong><small>one state/paint thread; deferred work after idle</small><span class="worker-badge worker-single" id="viewerWorkers">UI · 1 THREAD</span><div class="worker-bank worker-bank-serial" aria-label="One interactive UI thread"><span class="worker-box">UI</span></div></div>
</div>
<div class="channel-key"><span class="channel-key-mark">C</span><span class="channel-key-queue"><i></i><i></i><i></i></span><span>Shared bounded inboxes carry batches. The scanner fans out: outline summaries reach UI early; full directory batches feed builder shards.</span></div>
<div class="pass-rail"><span class="pass-label">A → FIRST USEFUL FRAME</span><span class="pass-line"></span><span class="pass-label pass-later">B → FULL TREE + IDLE PASSES</span></div>
<div class="lane-notes"><article><span class="lane-tag lane-io">I/O LANE</span><p id="ioLane">Walker workers read directories. A focus hint moves the folder currently on screen to the front of the queue.</p></article><article><span class="lane-tag lane-work">BUILD LANE</span><p>Builders own private trees in parallel; the final merge and replay is one serial finish step.</p></article><article><span class="lane-tag lane-ui">UI LANE</span><p>One interactive thread owns state and paint. Input stays responsive while I/O, previews and deferred refinement run elsewhere.</p></article></div>
</div>
<div class="principle-strip"><div><span class="principle-number">A</span><strong>Coarse now</strong><p>The outline branch reaches the UI while scanning continues; folders appear before the complete tree.</p></div><div><span class="principle-number">B</span><strong>Complete after</strong><p>Builder shards finish, then one merge/replay lands the full tree; FIEMAP and deferred layout follow.</p></div><div><span class="principle-number">C</span><strong>Bound every queue</strong><p>C marks shared bounded channels between producers and consumers, not a private pipe per worker.</p></div></div>
</div>
</section>
<section class="section scanner-section" id="scanners">
<div class="page-width">
<div class="section-heading"><div><p class="eyebrow">02 / The scanner family</p><h2>Same contract.<br><em>Different disks.</em></h2></div><p class="section-deck">Every backend yields per-directory batches. That seam keeps filesystem-specific tricks below the model, where they can be measured and refused without changing what a viewer consumes.</p></div>
<div class="scanner-layout">
<div class="scanner-rail" role="tablist" aria-label="Scanner internals"><button class="scanner-tab is-active" id="tab-linux" role="tab" aria-selected="true" aria-controls="scanner-detail" data-scanner="linux"><span>01</span> Linux</button><button class="scanner-tab" id="tab-macos" role="tab" aria-selected="false" aria-controls="scanner-detail" data-scanner="macos"><span>02</span> macOS</button><button class="scanner-tab" id="tab-windows" role="tab" aria-selected="false" aria-controls="scanner-detail" data-scanner="windows"><span>03</span> Windows</button><button class="scanner-tab" id="tab-volume" role="tab" aria-selected="false" aria-controls="scanner-detail" data-scanner="volume"><span>04</span> Direct metadata</button><button class="scanner-tab" id="tab-portable" role="tab" aria-selected="false" aria-controls="scanner-detail" data-scanner="portable"><span>05</span> Portable fallback</button></div>
<article class="scanner-detail" id="scanner-detail" role="tabpanel" aria-labelledby="tab-linux" aria-live="polite"><div class="detail-topline"><span class="detail-chip" id="scannerChip">LINUX / GENERIC PATH</span><span class="detail-index" id="scannerIndex">SCANNERS · 01</span></div><h3 id="scannerTitle">A directory stream, then a stat per entry.</h3><p class="detail-lead" id="scannerLead">Linux has no call that returns names and sizes together. duscape reads names with getdents64 and asks statx for sizes, identity and link counts. A worker pool overlaps that per-entry work across directories.</p><div class="detail-columns"><div><span class="mini-label">HOW IT STAYS FAST</span><p id="scannerFast">Three workers per core keep cold reads in flight; directory batches feed sharded tree builders. A later FIEMAP refinement checks small-file shared extents on XFS and btrfs.</p></div><div><span class="mini-label">WHAT IT GIVES UP</span><p id="scannerTradeoff">The generic path pays one metadata call per entry. Raw ext4 reads can be stale by seconds, require privilege, and are not faster warm on every machine.</p></div></div><div class="detail-code" id="scannerMechanism">getdents64 → statx → DirEntries → parallel::build_tree</div><div class="detail-foot" id="scannerFoot">Filesystem checks prevent duplicate bind mounts, pseudo filesystems and network mounts from masquerading as local space.</div></article>
</div>
<div class="scan-family-note"><span class="note-symbol">↳</span><p><strong>One honest seam:</strong> a walker emits the same directory facts; the shared tree, hard-link ledger, live outline, rescan protocol and viewers do not need to know how those facts were found.</p></div>
</div>
</section>
<section class="section viewer-section" id="viewers">
<div class="page-width">
<div class="section-heading"><div><p class="eyebrow">03 / The viewer family</p><h2>One model. Native hands.</h2></div><p class="section-deck">The desktop windows share state and layout policy. Each platform keeps only the input, window-system and paint code that genuinely belongs to it.</p></div>
<div class="viewer-grid">
<article class="viewer-card viewer-terminal"><div class="viewer-card-head"><span class="viewer-index">VIEW / 01</span><span class="viewer-badge">PRIMARY</span></div><h3>Terminal</h3><p class="viewer-sub">ratatui · crossterm</p><p>One terminal thread owns app state and renders on change. Input, scanning, preview work and the help-line ticker report instructions over channels. The grid uses terminal cells; nesting is cached by board generation.</p><div class="viewer-why"><span>FAST BY</span> rendering only when something changed</div><div class="viewer-file">viewers/tui/ · ui/grid/</div></article>
<article class="viewer-card viewer-windows"><div class="viewer-card-head"><span class="viewer-index">VIEW / 02</span><span class="viewer-badge">NATIVE</span></div><h3>Windows</h3><p class="viewer-sub">Win32 · GDI · DIB</p><p>A double-buffered pixel surface shares the common Viewer state. GDI measures text once, draws it with ExtTextOutW, and fills treemap pixels directly. NTFS volume roots can switch to the MFT when the sample says the table is worthwhile.</p><div class="viewer-why"><span>FAST BY</span> avoiding per-tile GDI overdraw</div><div class="viewer-file">viewers/windows/src/win/</div></article>
<article class="viewer-card viewer-macos"><div class="viewer-card-head"><span class="viewer-index">VIEW / 03</span><span class="viewer-badge">NATIVE</span></div><h3>macOS</h3><p class="viewer-sub">AppKit · objc2</p><p>AppKit draws the shared tree and nested map. Platform frameworks load when the window starts, not when the CLI launches. A saved scan streams onto screen, catches up through FSEvents, then fills trimmed small files.</p><div class="viewer-why"><span>FAST BY</span> showing saved state before catch-up</div><div class="viewer-file">viewers/macos/src/mac/</div></article>
<article class="viewer-card viewer-linux"><div class="viewer-card-head"><span class="viewer-index">VIEW / 04</span><span class="viewer-badge">NO TOOLKIT</span></div><h3>Linux desktop</h3><p class="viewer-sub">Wayland / X11 · software canvas</p><p>A software framebuffer is presented through pure-Rust Wayland or X11 backends. ab_glyph rasterizes system fonts; a bounded first paint defers deep labels and specks until input settles. No GTK, Qt, libwayland or Xlib at runtime.</p><div class="viewer-why"><span>FAST BY</span> drawing one owned canvas, then presenting it</div><div class="viewer-file">viewers/linux/src/ · viewers/shared/</div></article>
<article class="viewer-card viewer-dos"><div class="viewer-card-head"><span class="viewer-index">VIEW / 05</span><span class="viewer-badge">PORT</span></div><h3>MS-DOS</h3><p class="viewer-sub">16-bit real mode · FASM</p><p>A hand port, not a binding: scan, treemap, navigation and preview rewritten for a 286, with software IEEE doubles and text-mode colors. The Rust layout is its reference, and fixtures compare tile placement.</p><div class="viewer-why"><span>TRADEOFF</span> tiny footprint, separate implementation</div><div class="viewer-file">viewers/dos/ · make dos</div></article>
<article class="viewer-card viewer-shared"><div class="viewer-card-head"><span class="viewer-index">VIEW / SHARED</span><span class="viewer-badge">DESKTOPS</span></div><h3>Shared window state</h3><p class="viewer-sub">Viewer · Layout · passes</p><p>Selection, tree rows, nested hits, marks, delete prompts, rescans and preview generations live once in duscape-viewer. The UI toolkit paints and reports input; policy stays testable on every platform.</p><div class="viewer-why"><span>BOUNDARY</span> behavior shared, paint native</div><div class="viewer-file">viewers/shared/src/state.rs</div></article>
</div>
<figure class="shot-figure shot-wide"><img src="./img/window-overview.png" width="1382" height="853" loading="lazy" alt="The Windows window on a demo folder: on the left the folder's entries as a list, largest first, each folder with an expander; on the right a nested treemap of videos, photos by year, build output, a cache of small files and documents, each folder's tiles inside its own."><figcaption><span>FIG 02 · WINDOWS</span> The list and the nested treemap are one model: a folder's tile holds its entries' tiles, down to what the screen can show. The cache's thousands of small files fill their folders' tiles at the bottom.</figcaption></figure>
<div class="viewer-rule"><span class="rule-mark">≠</span><p>“Shared” does not mean “one renderer.” It means every desktop viewer inherits the same decisions about what is selected, what a nested tile means, and when expensive work may wait.</p></div>
</div>
</section>
<section class="section evidence-section" id="evidence">
<div class="page-width">
<div class="section-heading evidence-heading"><div><p class="eyebrow">04 / The numbers changed the design</p><h2>Keep the failed runs.</h2></div><p class="section-deck">These are not universal rankings. They are measurements with a machine, filesystem and condition attached. The negative results are part of the architecture.</p></div>
<div class="evidence-grid">
<article class="evidence-card evidence-macos"><div class="evidence-overline">MACOS / APFS · M4 PRO</div><div class="metric-pair"><div><strong>59.9<span>s</span></strong><small>before duplicate-volume skip</small></div><span class="metric-arrow">→</span><div><strong>36.5<span>s</span></strong><small>after, whole-disk scan</small></div></div><p>Firmlinks made the data volume reachable twice. The fix halved entries from 20.3M to 10.4M and stopped the total being about 1.6× used space. A lean attribute request alone was slightly slower on a single-volume tree.</p><div class="evidence-tag">STRUCTURE BEAT MICRO-OPTIMIZATION</div></article>
<article class="evidence-card evidence-linux"><div class="evidence-overline">LINUX / EXT4 · ROOT</div><div class="metric-pair"><div><strong>1.7<span>×</span></strong><small>cold speedup on VM</small></div><span class="metric-arrow">↔</span><div><strong>6–40<span>%</span></strong><small>cold gain on NVMe</small></div></div><p>On the VM the device walker is 1.7× faster cold than the same-privilege kernel walk. Bare-metal NVMe is different: it loses 20–30% warm, while cold gains only 6–40%. Sequential parsing can lose to parallel statx.</p><div class="evidence-tag">CONDITIONAL PATH, NOT A LAW</div></article>
<article class="evidence-card evidence-windows"><div class="evidence-overline">WINDOWS / NTFS · ELEVATED C:\</div><div class="metric-pair"><div><strong>6.1<span>s</span></strong><small>warm directory walk</small></div><span class="metric-arrow">→</span><div><strong>3.7<span>s</span></strong><small>warm MFT route</small></div></div><p>Reading the table sequentially cuts per-entry kernel work on a whole volume. But the same rule loses on a subtree or large-file data volume, so duscape samples directories and uses the MFT only when its cost model says so.</p><div class="evidence-tag">FAST PATH WITH A GATE</div></article>
<article class="evidence-card evidence-layout"><div class="evidence-overline">WINDOWS / TREEMAP · 87K-FILE FOLDER</div><div class="metric-pair"><div><strong>13.5<span>ms</span></strong><small>row inspected in full</small></div><span class="metric-arrow">→</span><div><strong>5.9<span>ms</span></strong><small>row ends decide squarify</small></div></div><p>With largest-first entries, a row's two ends determine its worst ratio and renderability. The pixel grid can hold tens of thousands of items; scanning every item in every row made the same layout quadratic-looking in practice.</p><div class="evidence-tag">ALGORITHM SHAPED BY THE PIXEL GRID</div></article>
<article class="evidence-card evidence-cache"><div class="evidence-overline">MACOS / SAVED SCAN · 8.1M ENTRIES</div><div class="metric-pair"><div><strong>28<span>s</span></strong><small>fresh scan</small></div><span class="metric-arrow">→</span><div><strong>0.5<span>s</span></strong><small>saved tree shown</small></div></div><p>Then catch-up completes in 2.6 s with totals identical to a fresh walk. The compact stream is about 3 bytes per entry; the first scan pays no measurable cost to record it.</p><div class="evidence-tag">SHOW · CATCH UP · FILL</div></article>
<article class="evidence-card evidence-frame"><div class="evidence-overline">DESKTOP PAINT · FIRST PASS</div><div class="metric-pair"><div><strong>33<span>ms</span></strong><small>maximized first frame</small></div><span class="metric-arrow">→</span><div><strong>7<span>ms</span></strong><small>deferred deep work</small></div></div><p>Nesting, tiny-file specks and labels adapt to a 10 ms relayout budget. The first useful picture is quick; the full layout and paint arrive after 60 ms of idle time.</p><div class="evidence-tag">DEFER, DO NOT DROP</div></article>
</div>
<div class="experiments"><div class="experiments-title"><span class="eyebrow">LAB NOTE / NEGATIVE RESULTS</span><h3>Good ideas that lost to measurement.</h3><p>Dead ends stay visible so the next optimization starts one step further along.</p></div><div class="experiment-list">
<details><summary><span class="experiment-mark">×</span><span><strong>io_uring statx</strong><small>Linux · batching looked promising</small></span><span class="experiment-result">3.8× slower</span></summary><p>Submission overhead and the way the kernel handled these metadata requests lost to plain statx. It is listed as not worth revisiting, not a dormant “maybe faster” path.</p></details>
<details><summary><span class="experiment-mark">×</span><span><strong>Adaptive worker counts</strong><small>Linux · ramp workers as they block</small></span><span class="experiment-result">3–4% slower cold</span></summary><p>The cold ramp cost more than it saved on warm runs, where wall time was not builder-bound. Revisit only with a machine whose core count substantially exceeds what its disk can feed.</p></details>
<details><summary><span class="experiment-mark">×</span><span><strong>More macOS workers</strong><small>APFS · kernel contention</small></span><span class="experiment-result">14 workers worse</span></summary><p>At eight workers the whole-disk scan used 185 seconds of system time against 7 seconds of user time; at fourteen, kernel time per entry rose from about 5 μs to 28 μs. The measured macOS cap is now six.</p></details>
<details><summary><span class="experiment-mark">×</span><span><strong>Drain the scan channel on quit</strong><small>macOS · a shutdown deadlock fix</small></span><span class="experiment-result">32.2s → 0.1s</span></summary><p>Draining freed blocked senders by accepting all their sends, which let workers finish the entire disk. A stop flag checked by the queue fixed the actual cancellation behavior.</p></details>
<details><summary><span class="experiment-mark">×</span><span><strong>“Closer” total from a parser bug</strong><small>macOS · plausible, completely wrong</small></span><span class="experiment-result">7.7M looked right</span></summary><p>A missing directory attribute shifted the parser into name bytes or dropped a subtree. The scan total looked closer to expected; the 233,390 unreadable entries exposed the bug. Counts and errors are checks, not decoration.</p></details>
</div></div>
</div>
</section>
<section class="section frames-section" id="frames">
<div class="page-width">
<div class="section-heading"><div><p class="eyebrow">05 / The window's frame</p><h2>Sixty frames a second.<br><em>Then the rest.</em></h2></div><p class="section-deck">The desktop viewers lay out and paint tens of thousands of tiles. Each frame does what fits in about 16 ms. The rest waits for a second pass, a worker thread, or the next frame. Here is what got them fast and looking right, and what didn't.</p></div>
<div class="evidence-grid">
<article class="evidence-card evidence-frame"><div class="evidence-overline">WINDOWS / LIVE SCAN · C:\USERS, WARM</div><div class="metric-pair"><div><strong>125<span>ms</span></strong><small>between updates</small></div><span class="metric-arrow">→</span><div><strong>17.9<span>ms</span></strong><small>about 56 fps</small></div></div><p>The view was starved, not slow: a relayout took 3 ms and a paint 8. The outline went out only every 4,096 entries, and the window waited 100 ms after it. Now the outline also flushes once a frame, and the window lays out and paints once a frame.</p><div class="evidence-tag">PACE BY THE FRAME, NOT THE BATCH</div></article>
<article class="evidence-card evidence-windows"><div class="evidence-overline">WINDOWS / FIRST FRAME AFTER A RELAYOUT</div><div class="metric-pair"><div><strong>18–21<span>ms</span></strong><small>before</small></div><span class="metric-arrow">→</span><div><strong>11–14<span>ms</span></strong><small>C:\Windows, E:\, 87k-file folder</small></div></div><p>The first paint of a new layout stops labelling tiles after 4 ms of labels. Once input has been still for 60 ms, a second pass paints everything. A layout painted in full stays that way, so labels never come and go as you hover.</p><div class="evidence-tag">HURRY ONCE, FINISH ONCE</div></article>
<article class="evidence-card evidence-layout"><div class="evidence-overline">WINDOWS / PAINTING NESTED TILES</div><div class="metric-pair"><div><strong>30<span>ms</span></strong><small>FillRect per tile</small></div><span class="metric-arrow">→</span><div><strong>13–17<span>ms</span></strong><small>4k tiles, pixels written direct</small></div></div><p>Fills and frames write straight into the DIB section's pixels. A folder is filled only around what its entries cover, so each level no longer repaints its parent's whole area.</p><div class="evidence-tag">DO NOT PAINT A PIXEL TWICE</div></article>
<article class="evidence-card evidence-linux"><div class="evidence-overline">SHARED / STEADY LAYOUT · ~</div><div class="metric-pair"><div><strong>8<span>%</span></strong><small>of tiles jumping per relayout</small></div><span class="metric-arrow">→</span><div><strong>2<span>%</span></strong><small>rows kept by name</small></div></div><p>A relayout of the same folder with new sizes keeps the last layout's rows (a <code>Plan</code>), so during a scan a growing folder swells in place instead of reshuffling every tile after it. At the scan's end, the area that moved fell from 14% to 2%.</p><div class="evidence-tag">LOOK STILL WHILE IT GROWS</div></article>
<article class="evidence-card evidence-cache"><div class="evidence-overline">SHARED / SMALL-FILE SPECKS · /USR, 2560×1400</div><div class="metric-pair"><div><strong>10.8<span>ms</span></strong><small>47k specks as tiles</small></div><span class="metric-arrow">→</span><div><strong>8.3<span>ms</span></strong><small>motes, colour runs</small></div></div><p>Entries too small for a tile are laid straight into one-pixel motes, with no Tile object for each. A file extension's colour is looked up once per run of the same type, not once per speck.</p><div class="evidence-tag">A PICTURE, NOT A TARGET</div></article>
<article class="evidence-card evidence-macos"><div class="evidence-overline">WINDOWS / SMALL-FILES CORNER · LUMINANCE</div><div class="metric-pair"><div><strong>2<span>×</span></strong><small>as bright as the tiles</small></div><span class="metric-arrow">→</span><div><strong>±5<span>%</span></strong><small>grid + 0.8 shade</small></div></div><p>Framed tiles show their colour inside a black frame; specks had none, so a corner of them read as a flat, glaring block. Specks now get the smallest tile's grid drawn over them and are darkened slightly, so the corner reads as more tiles of the same kinds.</p><div class="evidence-tag">MATCH THE TEXTURE, NOT THE AVERAGE</div></article>
</div>
<!-- Screenshots: the Windows window (release build) at 1400x900, 125% scale, 2026-10-05,
captured with PrintWindow after posted keys and clicks, client area only. Their folders
hold nothing personal: a generated demo tree under target/, C:\Windows, and a test
folder of numbered files. Crops are 2x, nearest neighbour. -->
<div class="shot-grid">
<figure class="shot-figure"><img src="./img/window-live-scan.png" width="1382" height="853" loading="lazy" alt="The window scanning C:\Windows: the treemap already laid out from the live outline, with folders sized by what the scan has found so far and the status bar reading scanning, 251,944 entries."><figcaption><span>FIG 03 · LIVE SCAN</span> 1.3 s into a scan of <code>C:\Windows</code>, from the outline: folders to six levels with running totals, laid out once a frame as batches arrive.</figcaption></figure>
<figure class="shot-figure"><img src="./img/window-delete.png" width="1382" height="853" loading="lazy" alt="The window deleting a node_modules folder of 30,000 files: a box over the treemap reads Deleting, node_modules, a progress bar, 18,857 of 30,031 removed, and a Cancel button."><figcaption><span>FIG 04 · DELETE</span> A delete runs on a thread of its own. After 100 ms a box shows how far it has got, with Cancel; whatever was only partly removed is rescanned.</figcaption></figure>
<figure class="shot-figure"><img src="./img/window-marks.png" width="1382" height="853" loading="lazy" alt="The docs folder opened in place in the list, three of its rows marked in yellow by a Shift-click range, and their tiles inside the docs tile marked yellow too; the panel reads 3 marked, 25.0M."><figcaption><span>FIG 05 · MARKS</span> A Shift-click range among the rows of a folder opened in place marks those rows, not the folder. The nested tiles show the same marks, and the paths are copied.</figcaption></figure>
<figure class="shot-figure"><img src="./img/window-specks-zoom.png" width="600" height="370" loading="lazy" alt="A close-up at twice the size: small framed tiles in several colours at the top and left; at the bottom right, a corner of one-pixel specks in the same colours under a fine dark grid, reading as more tiles."><figcaption><span>FIG 06 · SPECKS</span> 30,000 small files of six kinds, at 2×. The corner at the bottom right is specks, one or a few pixels each. Under the smallest tile's grid they read as more tiles.</figcaption></figure>
</div>
<figure class="shot-figure shot-pair"><img src="./img/window-specks-before-after.png" width="812" height="400" loading="lazy" alt="Two close-ups of the same corner of C:\Windows\WinSxS\Manifests at twice the size. Left, before: framed tiles around a flat, bright block of one colour. Right, after: the block is a fine grid in the same colour, about as bright as the tiles."><figcaption><span>FIG 07 · BEFORE / AFTER</span> <code>WinSxS\Manifests</code>, 39k manifests of one kind. Before, the specks were a flat block twice as bright as the framed tiles beside them; after, the same corner within 5% of them.</figcaption></figure>
<div class="experiments"><div class="experiments-title"><span class="eyebrow">KEPT / WHAT KEEPS A FRAME SHORT</span><h3>The tricks that stayed.</h3><p>Most are shared by all three desktop viewers through <code>duscape-viewer</code>; where one belongs to a platform, it says so.</p></div><div class="experiment-list">
<details><summary><span class="experiment-mark is-kept">✓</span><span><strong>Bound the work by the screen, not the folder</strong><small>layout · ranking · nesting</small></span><span class="experiment-result is-kept">a million entries cost what ten do</span></summary><p>A folder is ranked only as far as its tiles have room. Nesting stops where an inside is too small for two of the smallest tiles. The total number of tiles is capped by the area at the smallest tile size. The board is laid out in one-pixel cells, so there are as many tiles as the window can show, and no more.</p></details>
<details><summary><span class="experiment-mark is-kept">✓</span><span><strong>A deadline, and a second pass</strong><small>Nesting::deadline · room_cap · dust_deadline</small></span><span class="experiment-result is-kept">10 ms budget</span></summary><p>Nesting goes a level at a time across every folder, so a deadline cuts the deepest levels rather than leaving the last folders out entirely. No folder may take more than 1,000 tiles in the first pass. Specks come only while the last full layout predicts they fit in half the budget. Everything else is drawn once input has been still for 60 ms, and each new change pushes that back again.</p></details>
<details><summary><span class="experiment-mark is-kept">✓</span><span><strong>Indices, not paths</strong><small>NestedTile::parent · top</small></span><span class="experiment-result is-kept">half the nesting's time</span></summary><p>Cloning a path for every tile was half the nesting's cost. A nested tile now records its parent and top-level tile by index, and paths are worked out only when needed. The same rule applies to marks: which nested tiles are marked is computed once per paint, building paths only along the way to a mark, never per tile per mark.</p></details>
<details><summary><span class="experiment-mark is-kept">✓</span><span><strong>Text measured once, drawn with ExtTextOutW</strong><small>Windows · GDI</small></span><span class="experiment-result is-kept">DrawTextW cost 1.5×</span></summary><p>One <code>GetTextExtentExPointW</code> call gives where each character ends, so the ellipsis cut needs no second measurement. A font is selected only when it changes. The label font is the system message font, shrunk until the label band holds it whole.</p></details>
<details><summary><span class="experiment-mark is-kept">✓</span><span><strong>Keep the back buffer</strong><small>Windows · BackBuffer</small></span><span class="experiment-result is-kept">no page faults per frame</span></summary><p>The DIB section is created again only when the window size changes. A fresh one every frame had its memory pages faulted in on every paint.</p></details>
<details><summary><span class="experiment-mark is-kept">✓</span><span><strong>Paint when it is asked for, then let the paint happen</strong><small>Windows · PAINT_NOW · UpdateWindow</small></span><span class="experiment-result is-kept">one paint per relayout</span></summary><p>Windows makes <code>WM_TIMER</code> and <code>WM_PAINT</code> only when the message queue is empty, and a warm scan posts a batch every few milliseconds. So the batch that arrives after the frame is up does the layout itself, the timer only covers the last batch of a burst, and <code>UpdateWindow</code> paints as soon as the re-entrancy guard is down. Before this, one live relayout in three was ever painted.</p></details>
<details><summary><span class="experiment-mark is-kept">✓</span><span><strong>The system's frame loops run outside the guard</strong><small>Windows · HANDLED · DefWindowProcW</small></span><span class="experiment-result is-kept">resizes repaint live</span></summary><p>Dragging an edge, maximising, or opening the system menu all run modal loops inside <code>DefWindowProcW</code>, which send <code>WM_SIZE</code> and <code>WM_PAINT</code> back into the window procedure. Messages the window doesn't handle go straight to the system, outside the re-entrancy guard. Reports from other threads that arrive during a modal loop are queued in order and handled afterwards.</p></details>
<details><summary><span class="experiment-mark is-kept">✓</span><span><strong>Nothing that waits runs on the paint thread</strong><small>previews · deletes · rescans · drops</small></span><span class="experiment-result is-kept">40k entries deleted, window live</span></summary><p>Previews decode on their own thread at the size they will be drawn, 100 ms after the pointer settles, and a newer request supersedes an older one. A delete runs on its own thread and shows a box with a count and a Cancel button if it lasts beyond 100 ms. A replaced tree is freed on a thread of its own, because freeing millions of nodes takes time. AppKit is loaded with <code>dlopen</code> when the macOS window opens, which took the terminal viewer's cold start from 0.41 s to 0.07 s.</p></details>
<details><summary><span class="experiment-mark is-kept">✓</span><span><strong>Colour by name, never by rank</strong><small>tile_color · depth_shade</small></span><span class="experiment-result is-kept">no colour changes mid-scan</span></summary><p>Folders are blues; a file's colour comes from a hash of its extension, avoiding the blues and violets so a file never passes for a folder, in muted tones that white text reads on. Each level of nesting is 12% darker. The list's swatches use the same rule, so the list and the treemap agree as the listing re-sorts during a scan.</p></details>
<details><summary><span class="experiment-mark is-kept">✓</span><span><strong>Fixed things stay fixed</strong><small>free space band · unscanned strip</small></span><span class="experiment-result is-kept">the free space never moves</span></summary><p>A volume's free space is a band along the board's bottom, its size from the volume alone, so neither its place nor its shape changes during the scan. The unscanned space is a strip that narrows as the scan finds more. When the two were cut from one strip, the free space kept its area but kept changing shape, as if the free space itself were changing.</p></details>
<details><summary><span class="experiment-mark is-kept">✓</span><span><strong>Points for policy, pixels for paint</strong><small>Layout · set_pixel_scale</small></span><span class="experiment-result is-kept">one layout, any DPI</span></summary><p>The shared viewer works in points, and each window multiplies by its own scale to draw and divides to hit-test, so click targets match on every platform. Tiles are laid out in one-pixel cells, with a 4-pixel smallest tile, while the label band and margins stay fixed sizes in points.</p></details>
</div></div>
<div class="experiments"><div class="experiments-title"><span class="eyebrow">LAB NOTE / WHAT LOST</span><h3>Tried, measured, undone.</h3><p>Kept here so they are not tried again without a reason to think the numbers have changed.</p></div><div class="experiment-list">
<details><summary><span class="experiment-mark">×</span><span><strong>Lay out the live view per batch</strong><small>Windows · elevated whole-volume scan</small></span><span class="experiment-result">window froze</span></summary><p>Dozens of batches a second at 15–25 ms each: the window answered nothing until the scan ended. A 100 ms timer after a burst fixed the freeze but capped the view at 8 fps. A 16 ms timer after each batch reached only 23 fps, because a Windows timer ticks every 15.6 ms and only fires on an empty queue.</p></details>
<details><summary><span class="experiment-mark">×</span><span><strong>FillRect and FrameRect per tile</strong><small>Windows · GDI calls</small></span><span class="experiment-result">30 ms a frame</span></summary><p>The nested treemap overdraws heavily, and a GDI call per rectangle cost more than the layout. Writing pixels directly, with a <code>GdiFlush</code> whenever GDI has drawn since, replaced it.</p></details>
<details><summary><span class="experiment-mark">×</span><span><strong>Darken the specks to the tiles' average</strong><small>small-files corner · colour</small></span><span class="experiment-result">read darker still</span></summary><p>Scaled to the same average luminance as the framed tiles around it (52% of their colour on <code>WinSxS\Manifests</code>), the corner looked darker than them. The eye judges a framed tile by the colour inside its frame, not by the average. What worked was the grid's texture, plus a lighter shade.</p></details>
<details><summary><span class="experiment-mark">×</span><span><strong>Hide labels while tiles slide</strong><small>macOS · tween</small></span><span class="experiment-result">unreadable motion</span></summary><p>During a scan tiles slide almost all the time, and without labels the motion carried no information. Labels stay on while sliding (10.9 ms a frame on <code>~</code>). The Windows and Linux windows do not animate yet: their second pass, after 60 ms of idle, would snap every slide to its end.</p></details>
<details><summary><span class="experiment-mark">×</span><span><strong>Mark a folder for a range among its rows</strong><small>shared · marks as names</small></span><span class="experiment-result">the folder, not the rows</span></summary><p>Marks were top-level names, so a Shift range among the rows of a folder opened in place marked the folder itself. Marks are now row paths: a range runs over the rows as shown, closing a folder drops the marks inside it, and a delete takes a marked folder without also trying to delete marked rows inside it.</p></details>
</div></div>
</div>
</section>
<section class="closing-band"><div class="page-width closing-inner"><p class="eyebrow">THE DESIGN RULE</p><h2>Spend the frame on what<br>can change the frame.</h2><p>Everything else gets its own worker, bounded message, cheap first pass, or explicit platform gate.</p><a href="#top" class="back-top">Back to the route <span aria-hidden="true">↑</span></a></div></section>
</main>
<footer class="footer page-width"><span>DUSCAPE / INTERNALS EXPLAINER</span><span>Sources: <a href="../scan-performance.md">scan performance</a> · <a href="../scan-roadmap.md">roadmap</a> · <a href="../viewers.md">viewers</a> · <a href="../../AGENTS.md">architecture notes</a></span></footer>
</body>
</html>