A treemap for finding and removing what fills your disk, for Omarchy. Rust + GPUI.
Rust
scan: profile SSH indexing and deduplicate hardlinks on the desktop
Tobi Lutke71868f672ad8
diff --git a/README.md b/README.mdindex 625ec18..6097a1a 100644--- a/README.md+++ b/README.md@@ -213,10 +213,13 @@ so outdated helpers reject them instead of silently scanning their home.The Linux/macOS helper streams a depth-first walk directly to stdout. Itnever constructs a tree or retains a directory's children: memory scaleswith open ancestors, not file count. Deep directories are not rejected-at an arbitrary depth; filesystem errors are reported as unreadable. Only pending hardlink-identities are retained, capped at 65,536; ordinary files need no identity-storage. A resource limit fails explicitly instead of returning a partial-tree. Symlinks are not followed and every nested mount is skipped, even a+at an arbitrary depth; filesystem errors are reported as unreadable.+Hardlink identities are sent to the desktop, which uses the local scanner's+compact identity index to count each inode once. The helper keeps no+per-file identity table in negotiated desktop-de-duplication mode; links+outside the chosen root cannot fill one. Older clients retain bounded+helper-side accounting for wire compatibility. A resource limit fails+explicitly instead of returning a partial tree. Symlinks are not followed and every nested mount is skipped, even abind mount or same-device subvolume. Select those as separate roots.While indexing, the window shows live files, directories, measured bytes,diff --git a/crates/disktree-core/examples/profile_remote.rs b/crates/disktree-core/examples/profile_remote.rsnew file mode 100644index 0000000..862c8a2--- /dev/null+++ b/crates/disktree-core/examples/profile_remote.rs@@ -0,0 +1,113 @@+//! Disposable-fixture profiling; no default path and no SSH or deployment.+use std::fs::File;+use std::io::{self, BufReader, BufWriter, Write as _};+use std::path::Path;+use std::time::Instant;++use disktree_core::remote::{read_snapshot, serve};+use disktree_core::scan::{ScanOptions, scan};++fn main() -> io::Result<()> {+ let args: Vec<_> = std::env::args().collect();+ let mode = args.get(1).map_or("", String::as_str);+ let path = Path::new(args.get(2).ok_or_else(|| {+ io::Error::other(+ "usage: profile_remote generate|decode|stream|scan PATH",+ )+ })?);+ if !path.starts_with(std::env::temp_dir()) {+ return Err(io::Error::other(+ "profiling requires a disposable temp path",+ ));+ }+ let started = Instant::now();+ match mode {+ "generate" => {+ let mut out = BufWriter::new(File::create_new(path)?);+ let count = args+ .get(3)+ .and_then(|s| s.parse().ok())+ .unwrap_or(500_000_u64);+ writeln!(+ out,+ "{}",+ serde_json::json!({+ "version": 1, "root": "/tmp/profile-fixture",+ "home": null, "disk_root": null, "space": null,+ "platform": "linux", "identity": null,+ })+ )?;+ for index in 0..count {+ writeln!(out, "[\"file-{index}\",1,4096,1,0,false,0]")?;+ }+ writeln!(out, "[\"root\",0,0,0,0,false,{count}]\n\"done\"")?;+ out.flush()?;+ }+ "decode" => {+ let snapshot =+ read_snapshot(&mut BufReader::new(File::open(path)?))?;+ eprintln!(+ "files={} bytes={}",+ snapshot.tree.files, snapshot.tree.bytes+ );+ }+ "scan" => {+ let tree = scan(path, ScanOptions::default())?;+ eprintln!("files={} bytes={}", tree.files, tree.bytes);+ }+ "ssh" | "ssh-plain" => {+ use std::process::{Command, Stdio};+ let config = args.get(3).ok_or_else(|| {+ io::Error::other("missing fixture SSH config")+ })?;+ let helper = args+ .get(4)+ .ok_or_else(|| io::Error::other("missing helper path"))?;+ if !Path::new(config).starts_with(std::env::temp_dir()) {+ return Err(io::Error::other(+ "only isolated fixture SSH configs",+ ));+ }+ let mut command = Command::new("ssh");+ command.args(["-F", config, "-T"]);+ if mode == "ssh" {+ command.arg("-C");+ }+ let mut child = command+ .args(["fixture", helper, "--stdio-v1"])+ .stdin(std::process::Stdio::piped())+ .stdout(Stdio::piped())+ .spawn()?;+ let mut input = child.stdin.take().expect("piped stdin");+ writeln!(+ input,+ "{}",+ serde_json::json!({+ "root": path, "disk": false, "options": ScanOptions::default(),+ "live_progress": true, "client_dedup": true,+ })+ )?;+ drop(input);+ let snapshot = read_snapshot(&mut BufReader::new(+ child.stdout.take().expect("piped stdout"),+ ))?;+ if !child.wait()?.success() {+ return Err(io::Error::other("fixture SSH failed"));+ }+ eprintln!("files={}", snapshot.tree.files);+ }+ "stream" => {+ let request = serde_json::to_vec(&serde_json::json!({+ "root": path, "disk": false, "options": ScanOptions::default(),+ "live_progress": true, "client_dedup": true,+ }))?;+ let mut input = request;+ input.push(b'\n');+ let mut output = BufWriter::new(io::stdout().lock());+ serve(&mut input.as_slice(), &mut output)?;+ }+ _ => return Err(io::Error::other("unknown profile mode")),+ }+ eprintln!("{mode} elapsed={:.3}s", started.elapsed().as_secs_f64());+ Ok(())+}diff --git a/crates/disktree-core/src/remote.rs b/crates/disktree-core/src/remote.rsindex cbe453b..07d3edd 100644--- a/crates/disktree-core/src/remote.rs+++ b/crates/disktree-core/src/remote.rs@@ -62,6 +62,8 @@ pub struct SessionRequest {// Opt-in keeps the postorder-only wire format for older clients.#[serde(default)]pub live_progress: bool,+ #[serde(default)]+ pub client_dedup: bool,}/// The target's root candidates, without walking or probing any of them.@@ -119,6 +121,13 @@ pub(crate) struct Record(pub usize,);+#[derive(Deserialize)]+struct Control {+ directory: Option<PathBuf>,+ entry: Option<Record>,+ link: Option<(u64, u64)>,+}+fn json_error(error: serde_json::Error) -> io::Error {io::Error::new(io::ErrorKind::InvalidData, error)}@@ -135,9 +144,15 @@ fn receive<T: serde::de::DeserializeOwned>(input: &mut impl BufRead,) -> io::Result<T> {let mut line = String::new();+ receive_line(input, &mut line)?;+ serde_json::from_str(&line).map_err(json_error)+}++fn receive_line(input: &mut impl BufRead, line: &mut String) -> io::Result<()> {+ line.clear();// A remote process is not trusted to allocate arbitrary amounts of RAM// with a single malformed record (or an accidental login banner).- let length = input.take(MAX_LINE).read_line(&mut line)?;+ let length = input.take(MAX_LINE).read_line(line)?;if length == 0 {return Err(io::Error::new(io::ErrorKind::UnexpectedEof,@@ -152,7 +167,7 @@ fn receive<T: serde::de::DeserializeOwned>(};return Err(io::Error::new(io::ErrorKind::InvalidData, reason));}- serde_json::from_str(&line).map_err(json_error)+ Ok(())}/// Only read-only discovery and scans: no command execution or removal.@@ -171,9 +186,12 @@ pub fn serve_session(out: &mut impl Write,) -> io::Result<()> {match session.operation {- Operation::Scan(request) => {- serve_request_with_progress(request, out, session.live_progress)- }+ Operation::Scan(request) => serve_request_with_progress(+ request,+ out,+ session.live_progress,+ session.client_dedup,+ ),Operation::Discover { discover_version } => {if discover_version != VERSION {return Err(io::Error::other(@@ -197,15 +215,16 @@ pub fn serve_session(/// Scan a decoded request. The standalone helper supervises its lifetime.pub fn serve_request(request: Request, out: &mut impl Write) -> io::Result<()> {- serve_request_with_progress(request, out, false)+ serve_request_with_progress(request, out, false, false)}fn serve_request_with_progress(request: Request,out: &mut impl Write,live_progress: bool,+ client_dedup: bool,) -> io::Result<()> {- let _ = live_progress; // Only Unix has the streaming walker.+ let _ = (live_progress, client_dedup); // Only Unix has the streaming walker.let home = std::env::home_dir();let root = request.root@@ -234,7 +253,13 @@ fn serve_request_with_progress()?;out.flush()?;#[cfg(unix)]- crate::remote_walk::stream(&root, &request.options, out, live_progress)?;+ crate::remote_walk::stream(+ &root,+ &request.options,+ out,+ live_progress,+ client_dedup,+ )?;#[cfg(not(unix))]write_node(out, &scan(&root, request.options)?)?;// An explicit terminator distinguishes a complete scan from a severed SSH@@ -293,23 +318,48 @@ fn read_snapshot_with_progress(*shared.lock().expect("remote progress lock") = progress.clone();let mut published = Instant::now();let mut stack = Vec::<Node>::new();+ let mut line = String::new();+ let seen = crate::tree::Seen::new();loop {- let value: serde_json::Value = receive(input)?;- if value == "done" {+ receive_line(input, &mut line)?;+ let text = line.trim_start();+ // The common path is a typed tuple, not a heap-allocated JSON DOM+ // followed by another deserialization. Reuse the line allocation.+ let record: Record = if text.starts_with('[') {+ serde_json::from_str(text).map_err(json_error)?+ } else if text.starts_with('{') {+ let control: Control =+ serde_json::from_str(text).map_err(json_error)?;+ if let Some(directory) = control.directory {+ progress.directory = Some(directory);+ progress.updated = Some(Instant::now());+ *shared.lock().expect("remote progress lock") =+ progress.clone();+ published = Instant::now();+ continue;+ }+ let mut entry = control.entry.ok_or_else(|| {+ io::Error::other("invalid remote control record")+ })?;+ let identity = control.link.ok_or_else(|| {+ io::Error::other("missing remote hardlink identity")+ })?;+ if entry.1 != 1 || entry.6 != 0 {+ return Err(io::Error::other("invalid remote hardlink entry"));+ }+ if entry.2 > 0 && !seen.insert(identity) {+ entry.2 = 0;+ }+ entry+ } else if serde_json::from_str::<String>(text).map_err(json_error)?+ == "done"+ {break;- }- if let Some(directory) = value.get("directory") {- progress.directory = Some(- serde_json::from_value(directory.clone())- .map_err(json_error)?,- );- progress.updated = Some(Instant::now());- *shared.lock().expect("remote progress lock") = progress.clone();- published = Instant::now();- continue;- }+ } else {+ return Err(io::Error::other("invalid remote stream marker"));+ };let Record(name, kind, bytes, files, modified, read_error, count) =- serde_json::from_value(value).map_err(json_error)?;+ record;// Names must remain single components when joined to marked paths.if name.is_empty()|| name == "."@@ -579,6 +629,7 @@ impl<T: Send + 'static> RemoteJob<T> {operation,watch_disconnect: true,live_progress: true,+ client_dedup: true,},)?;decode(&mut input, &live)@@ -721,6 +772,7 @@ mod tests {},watch_disconnect: true,live_progress: true,+ client_dedup: true,};let bytes = serde_json::to_vec(&session).unwrap();assert!(serde_json::from_slice::<Request>(&bytes).is_err());@@ -1072,6 +1124,85 @@ mod tests {assert_eq!(shared.lock().unwrap().stage, Stage::Finalizing);}+ #[test]+ fn desktop_dedup_counts_links_once_without_requiring_external_names() {+ let dir = tempfile::tempdir().unwrap();+ let root = dir.path().join("root");+ std::fs::create_dir(&root).unwrap();+ std::fs::write(root.join("first"), b"hello").unwrap();+ std::fs::hard_link(root.join("first"), root.join("alias")).unwrap();+ std::fs::hard_link(root.join("first"), dir.path().join("outside"))+ .unwrap();+ for dedup in [true, false] {+ let session = SessionRequest {+ operation: Operation::Scan(Request {+ root: Some(root.clone()),+ disk: false,+ options: ScanOptions {+ apparent_size: true,+ dedup_hardlinks: dedup,+ ..ScanOptions::default()+ },+ }),+ live_progress: true,+ client_dedup: true,+ watch_disconnect: false,+ };+ let mut data = Vec::new();+ serve_session(session, &mut data).unwrap();+ let snapshot = read_snapshot(&mut data.as_slice()).unwrap();+ assert_eq!(snapshot.tree.bytes, if dedup { 5 } else { 10 });+ assert_eq!(snapshot.tree.files, 2);+ }+ }++ #[test]+ fn desktop_dedup_accepts_more_than_the_old_pending_link_limit() {+ let mut data = Vec::new();+ send(+ &mut data,+ &Header {+ version: VERSION,+ root: std::env::temp_dir().join("links-test"),+ home: None,+ disk_root: None,+ space: None,+ platform: std::env::consts::OS.into(),+ identity: None,+ },+ )+ .unwrap();+ let count = 65_537_u64;+ for index in 0..=count {+ let inode = if index == count { 42 } else { index };+ send(+ &mut data,+ &serde_json::json!({+ "link": [7, inode],+ "entry": [format!("file-{index}"), 1, 1, 1, 0, false, 0],+ }),+ )+ .unwrap();+ }+ send(+ &mut data,+ &Record(+ "root".into(),+ 0,+ 0,+ 0,+ 0,+ false,+ usize::try_from(count + 1).unwrap(),+ ),+ )+ .unwrap();+ send(&mut data, &"done").unwrap();+ let snapshot = read_snapshot(&mut data.as_slice()).unwrap();+ assert_eq!(snapshot.tree.files, count + 1);+ assert_eq!(snapshot.tree.bytes, count);+ }+#[test]fn protocol_roundtrip_and_truncation() {let dir = tempfile::tempdir().unwrap();diff --git a/crates/disktree-core/src/remote_walk.rs b/crates/disktree-core/src/remote_walk.rsindex b845070..7193b79 100644--- a/crates/disktree-core/src/remote_walk.rs+++ b/crates/disktree-core/src/remote_walk.rs@@ -10,7 +10,8 @@ use rustc_hash::{FxHashMap, FxHashSet};use crate::remote::{Record, send};use crate::scan::{ScanOptions, measure, modified_seconds};-// Only unresolved multiply linked files need a file-identity table.+// Legacy peers require helper-side accounting. Modern clients explicitly+// negotiate desktop de-duplication and never populate this table.const MAX_PENDING_LINKS: usize = 65_536;struct Frame {@@ -34,6 +35,7 @@ pub fn stream(options: &ScanOptions,out: &mut impl Write,live_progress: bool,+ client_dedup: bool,) -> io::Result<()> {if options.follow_links || !options.one_filesystem {return Err(io::Error::other(@@ -47,7 +49,14 @@ pub fn stream(})?;let mut excluded: FxHashSet<PathBuf> = boundaries.into_iter().collect();excluded.extend(crate::space::never_scanned(root, root));- stream_with_boundaries(root, options, &excluded, out, live_progress)+ stream_with_boundaries(+ root,+ options,+ &excluded,+ out,+ live_progress,+ client_dedup,+ )}fn stream_with_boundaries(@@ -56,11 +65,12 @@ fn stream_with_boundaries(excluded: &FxHashSet<PathBuf>,out: &mut impl Write,live_progress: bool,+ client_dedup: bool,) -> io::Result<()> {let device = fs::metadata(root)?.dev();let mut frames = vec![Frame::open(root, "root".into())];- // Ordinary single-link files need no identity storage. Forget a shared- // inode once all its names were met, and bound unmatched identities.+ // Only the legacy wire mode needs a table. Modern sessions emit each+ // hardlink's identity directly and leave this map empty.let mut links = FxHashMap::<(u64, u64), u64>::default();let mut directory = root.to_path_buf();let mut heartbeat = None::<std::time::Instant>;@@ -130,7 +140,9 @@ fn stream_with_boundaries(} else {measure(&meta, options.apparent_size)};- if options.dedup_hardlinks && meta.is_file() && meta.nlink() > 1 {+ let hardlinked =+ options.dedup_hardlinks && meta.is_file() && meta.nlink() > 1;+ if hardlinked && !client_dedup {let identity = (meta.dev(), meta.ino());if let Some(remaining) = links.get_mut(&identity) {bytes = 0;@@ -148,18 +160,33 @@ fn stream_with_boundaries(links.insert(identity, meta.nlink() - 1);}}- send(- out,- &Record(- name.to_owned(),- kind,- bytes,- u64::from(meta.is_file()),- modified_seconds(&meta),- false,- 0,- ),- )?;+ let record = Record(+ name.to_owned(),+ kind,+ bytes,+ u64::from(meta.is_file()),+ modified_seconds(&meta),+ false,+ 0,+ );+ if hardlinked && client_dedup {+ // The desktop already owns the tree and its compact identity+ // index. The server retains no per-file state in this mode.+ #[derive(serde::Serialize)]+ struct Linked<'a> {+ link: (u64, u64),+ entry: &'a Record,+ }+ send(+ out,+ &Linked {+ link: (meta.dev(), meta.ino()),+ entry: &record,+ },+ )?;+ } else {+ send(out, &record)?;+ }frames.last_mut().expect("parent exists").record.6 += 1;}Ok(())@@ -181,6 +208,7 @@ mod tests {&excluded.iter().cloned().collect(),&mut bytes,false,+ false,).unwrap();bytes@@ -274,7 +302,8 @@ mod tests {},] {assert!(- stream(dir.path(), &options, &mut Vec::new(), false).is_err()+ stream(dir.path(), &options, &mut Vec::new(), false, false)+ .is_err());}}diff --git a/crates/disktree-core/src/tree.rs b/crates/disktree-core/src/tree.rsindex 42b1566..4bbeda4 100644--- a/crates/disktree-core/src/tree.rs+++ b/crates/disktree-core/src/tree.rs@@ -333,7 +333,7 @@ impl Seen {}/// Whether `key` is new.- fn insert(&self, key: (u64, u64)) -> bool {+ pub(crate) fn insert(&self, key: (u64, u64)) -> bool {let (volume, number) = key;if *self.volume.get_or_init(|| volume) == volume && number < Self::BITS{diff --git a/crates/disktree-scan/tests/stdio.rs b/crates/disktree-scan/tests/stdio.rsindex 6d9a441..aed13b1 100644--- a/crates/disktree-scan/tests/stdio.rs+++ b/crates/disktree-scan/tests/stdio.rs@@ -172,14 +172,36 @@ fn wide_stream_has_bounded_resident_memory() {std::fs::File::create(dir.path().join(format!("file-{index:06}"))).unwrap();}+ assert_bounded_stream_memory(dir.path());+}++#[cfg(target_os = "linux")]+#[test]+#[ignore = "creates 70,000 hardlinks to inodes outside the scanned fixture"]+fn external_hardlinks_have_bounded_resident_memory() {+ let dir = tempfile::tempdir().unwrap();+ let root = dir.path().join("root");+ let outside = dir.path().join("outside");+ std::fs::create_dir(&root).unwrap();+ std::fs::create_dir(&outside).unwrap();+ for index in 0..70_000 {+ let file = outside.join(format!("file-{index}"));+ std::fs::File::create(&file).unwrap();+ std::fs::hard_link(&file, root.join(format!("file-{index}"))).unwrap();+ }+ assert_bounded_stream_memory(&root);+}++#[cfg(target_os = "linux")]+fn assert_bounded_stream_memory(root: &std::path::Path) {let mut helper = supervised_helper();let mut input = helper.0.stdin.take().unwrap();serde_json::to_writer(&mut input,&serde_json::json!({- "root": dir.path(), "disk": false,+ "root": root, "disk": false,"options": ScanOptions::default(), "watch_disconnect": true,- "live_progress": true,+ "live_progress": true, "client_dedup": true,}),).unwrap();diff --git a/docs/ssh-profiling.md b/docs/ssh-profiling.mdnew file mode 100644index 0000000..f9dcaa7--- /dev/null+++ b/docs/ssh-profiling.md@@ -0,0 +1,98 @@+# SSH indexing profile++Measured on 2026-10-22, Intel Core Ultra X7 358H (16 CPUs), release builds.+All fixtures were disposable local **tmpfs** trees with warm metadata.+These are component measurements, not a profile of a6000's storage or UI.+Decode timings include tree destruction at the end of each invocation.+A read-only process check found no active helper there; no new real-server+scan was started. No caches were dropped and no limits were raised.++## Results++| Component / fixture | Before | After |+| --- | ---: | ---: |+| Decode + aggregate + classify 500,000 wire records | 288.3 ± 13.7 ms | 210.2 ± 2.2 ms |+| Stream 100,000 files, output discarded | 103.4 ± 2.7 ms | 101.2 ± 2.0 ms |+| Parallel local scan, 100,000 files, earlier paired run | 21.5 ± 0.5 ms | unchanged |+| Serial streaming, same earlier paired run | 86.8 ± 2.6 ms | — |+| Actual static helper + localhost SSH + decode, 100,000 files | — | 321–347 ms uncompressed; 316–334 ms compressed |+| Helper RSS, 70,000 external hardlinks, 20k / 40k records | scan aborted at 65,536 identities | 2,888 / 2,888 KiB; completes |++Hyperfine used warmups and 5–7 trials. SSH used five trials per mode and an+isolated sshd, temporary keys/config, the shipped static musl helper and no+user SSH settings. SSH measurements include connection/authentication but+not automatic deployment. Do not subtract these runs to claim a precise+network cost: the implementations differ and work overlaps.++### Findings++1. **Avoidable decoder work.** `perf record` showed generic+ `serde_json::Value` construction followed by a second deserialization.+ Every record also allocated a new line buffer. Direct tuple/control+ decoding and one reused line buffer reduced this fixture's decode time+ by 27% (1.37× throughput). This is not a 27% end-to-end scan improvement.+2. **Serial metadata remains the main walker limitation.** In a paired+ fixture, the existing parallel local scanner was 4.04× faster than the+ serial streaming helper. Streaming time did not materially change after+ the decoder fix. Bounded metadata concurrency is the next substantial+ scanner optimization; reverting to the full tree-building local engine+ on the server would bring back file-count-scaled memory.+3. **Compression is not the explanation on loopback.** The compressed and+ uncompressed ranges overlap. This says nothing about a slower real link.+4. **The hardlink failure was our bookkeeping policy, not memory pressure.**+ `nlink` includes names outside the scanned root. Tracking “remaining+ names” cannot drain for such files, so ordinary uv/package caches hit+ the 65,536-entry cap. Modern sessions now negotiate `client_dedup`:+ the helper emits `(device, inode)` with linked file records and keeps no+ identity table. The desktop uses the local scanner's existing `Seen`+ bitmap/sharded set. In-root aliases are charged once; external names+ need not be visited. Legacy peers retain the old bounded wire mode.++The after-profile shows tree sorting/classification, typed JSON parsing,+line reading and clock checks as remaining desktop costs. Its wide,+single-directory fixture exaggerates sorting relative to ordinary trees.+A future profile of an already-running real scan should distinguish helper+CPU, filesystem wait, SSH throughput and desktop finalization before+attributing its wall time to any one of these synthetic results.++## Reproduce safely++```sh+cargo build -p disktree-core --example profile_remote --release \+ --config profile.release.debug=1++target/release/examples/profile_remote generate /tmp/disktree-wire.jsonl+hyperfine --warmup 1 --runs 7 \+ 'target/release/examples/profile_remote decode /tmp/disktree-wire.jsonl'+perf record -g --call-graph dwarf -- \+ target/release/examples/profile_remote decode /tmp/disktree-wire.jsonl+perf report+```++For an explicitly created disposable fixture under+`/tmp/disktree-profile-*`, compare `scan PATH` and `stream PATH >/dev/null`+with that example. It refuses non-temporary paths; it has no default root.+The SSH profiler uses the existing isolated test harness:++```sh+DISKTREE_PROFILE_ROOT=/tmp/disktree-profile-fixture \+ bun scripts/test-ssh.ts+```++That directory must already exist and contain only your disposable test+files. The harness automatically builds the portable helper and requires+the `profile_remote` example built above. Without the environment variable,+it runs the normal four SSH integration tests instead.++Memory/failure regressions against the actual helper executable:++```sh+cargo test -p disktree-scan --test stdio \+ external_hardlinks_have_bounded_resident_memory -- --ignored --nocapture+cargo test -p disktree-scan --test stdio \+ wide_stream_has_bounded_resident_memory -- --ignored --nocapture+```++Both create and clean their own temporary fixtures. The regular core suite+also verifies more than 65,536 identities, duplicate aliases, external+names, disabled de-duplication, legacy records and complete framing.diff --git a/scripts/test-ssh.ts b/scripts/test-ssh.tsindex 9326758..121a740 100644--- a/scripts/test-ssh.ts+++ b/scripts/test-ssh.ts@@ -41,8 +41,16 @@ try {});console.log(`Testing a real SSH connection to isolated sshd on localhost:${port}`);run('ssh',['-F',client,'fixture','true']);- run('cargo',['test','-p','disktree-core','real_ssh_transport_','--','--ignored','--nocapture'], {...process.env,DISKTREE_TEST_SSH_CONFIG:client,DISKTREE_TEST_HELPER:join(process.cwd(),`target/${process.arch === 'arm64' ? 'aarch64' : 'x86_64'}-unknown-linux-musl/release/disktree-scan`),DISKTREE_TEST_ARCHIVE:join(process.cwd(),'target/portable/disktree')});- console.log('REAL SSH SCAN PASSED. Temporary host key, client key and server will be removed.');+ if (process.env.DISKTREE_PROFILE_ROOT) {+ const root = process.env.DISKTREE_PROFILE_ROOT;+ if (!root.startsWith(join(tmpdir(), 'disktree-profile-'))) throw new Error('Only disposable profile fixtures allowed');+ const binary = join(process.cwd(), 'target/release/examples/profile_remote');+ const helper = join(process.cwd(), `target/${process.arch === 'arm64' ? 'aarch64' : 'x86_64'}-unknown-linux-musl/release/disktree-scan`);+ for (const mode of ['ssh-plain', 'ssh']) {+ for (let trial=0; trial<5; trial++) run(binary, [mode,root,client,helper]);+ }+ } else run('cargo',['test','-p','disktree-core','real_ssh_transport_','--','--ignored','--nocapture'], {...process.env,DISKTREE_TEST_SSH_CONFIG:client,DISKTREE_TEST_HELPER:join(process.cwd(),`target/${process.arch === 'arm64' ? 'aarch64' : 'x86_64'}-unknown-linux-musl/release/disktree-scan`),DISKTREE_TEST_ARCHIVE:join(process.cwd(),'target/portable/disktree')});+ console.log(`${process.env.DISKTREE_PROFILE_ROOT ? 'SSH PROFILING COMPLETE' : 'REAL SSH SCAN PASSED'}. Temporary host key, client key and server will be removed.`);} finally {if (server && server.exitCode === null) {server.kill('SIGTERM');