Skip to content

Don't rewrite it in Rust. Rewrite the 5% that's slow: profile your app, port the hot functions with your coding agent, prove they behave the same. Python, JS/TS, Ruby, Java, Kotlin, Go, PHP, C/C++, C#, R.

node: the low-attribution note says where the run went, without repeating the scan's own notes (#164)

EL4CTEOe9b144439ca4
diff --git a/src/node.rs b/src/node.rs
index 52da8ad..81ac640 100644
--- a/src/node.rs
+++ b/src/node.rs
@@ -3095,11 +3095,9 @@ assert.ok(!same([Number.MAX_VALUE, Infinity], [Number.MAX_VALUE, Number.MAX_VALU
assert_eq!(notes.len(), 1, "expected low-attribution note, got {notes:?}");
let note = notes[0].as_str().unwrap();
assert!(
- note.contains("only 20.0% of the profiled run landed in your own named functions")
- && note.contains("node:vm 50%")
+ note.starts_with("only 20.0% of the run is in your own named functions; the rest went to node:vm 50%")
&& note.contains("fast-glob 20%")
- && note.contains("top-level / anonymous code 10%")
- && note.contains("V8's sampling profiler doesn't count calls"),
+ && note.contains("top-level / anonymous code 10%"),
"unexpected note: {note}"
);
diff --git a/src/node/runner.mjs b/src/node/runner.mjs
index cba47d0..2f1f526 100644
--- a/src/node/runner.mjs
+++ b/src/node/runner.mjs
@@ -983,10 +983,10 @@ function profile(job) {
.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
.slice(0, 3)
.map(([l, us]) => `${l} ${Math.round((us / 1e6 / denom) * 100)}%`);
- const where = top.length ? ` (the rest went to ${top.join(", ")})` : "";
- notes.push(
- `only ${(share * 100).toFixed(1)}% of the profiled run landed in your own named functions${where}; V8's sampling profiler doesn't count calls`,
- );
+ // the scan's own notes already say there are no call counts and that most of the run is
+ // outside the app's functions; this one says where it went instead (#164)
+ if (top.length)
+ notes.push(`only ${(share * 100).toFixed(1)}% of the run is in your own named functions; the rest went to ${top.join(", ")}`);
}
writeFileSync(job.out, JSON.stringify({ wall: total, base: ".", functions, notes }));
}