Open mbrevda opened 10 months ago
Hey! As far as I remember, there's no circumstance where source-maps are automatically applied. That said, speedscope lets you apply sourcemaps after-the-fact.
See #317
speedscope lets you apply sourcemaps after-the-fact.
Thats cool! Unfortunately, dropping sourcemaps doesn't seem to have any effect on paths or symbols. Is there another way to load them that I can try?
Could this be related to esm code? I tried generating my code as .js
(from .mjs
) but that didn't help. Any way to debug sourcemaps to see if they are finding anything to apply?
I'm not sure offhand if this would have anything to do with esm!
If you want to debug, your best bet would be to step through the code here: https://github.com/jlfwong/speedscope/blob/de17f128d0ce9d2a696ac7772dec6393dc2888b4/src/lib/js-source-map.ts#L75
To get up and running locally, check out https://github.com/jlfwong/speedscope/blob/main/CONTRIBUTING.md
Good call! It seems that the prof traces aren't having their filename/line/column populated. Not sure if this is the best way to do it, but the following patch fixes that:
diff --git a/src/lib/profile.ts b/src/lib/profile.ts
index 4e04742..13b189b 100644
--- a/src/lib/profile.ts
+++ b/src/lib/profile.ts
@@ -66,6 +66,15 @@ export class Frame extends HasWeights {
private constructor(info: FrameInfo) {
super()
+ if (!info.file && !info.line && !info.col) {
+ const matches = info.name.match(/(?:\/\/?)?([^:]+):(\d+):(\d+)/)
+ if (matches) {
+ info.file = matches[1]
+ info.line = parseInt(matches[2], 10)
+ info.col = parseInt(matches[3], 10)
+ }
+ }
+
this.key = info.key
this.name = info.name
this.file = info.file
However, even with this patch, the frames aren't remapped to their proper sources.
Hi - trying to run speedscope to help optimize program startup. It doesn't seem like sourcemaps are being applied, making tracing operations challenging.
Here is a standalone script that closely mimics my setup, illustrating the issue:
test.sh
```sh set -e tmpdir=$(mktemp -d) cat << EOF > $tmpdir/bar.ts import http from "node:http"; function listenCallBack() { console.log("Server is running"); setTimeout(() => { console.log("exiting server..."); process.exit(0); }, 100); }; const server = () => { const server = http.createServer((req, res) => { res.end("Hello World"); }); server.listen("8080", listenCallBack); return server; }; export default server; EOF cat << EOF > $tmpdir/index.ts import('./bar.ts').then((bar) => bar.default()); EOF cd $tmpdir npx esbuild --bundle --splitting --minify --sourcemap=linked --platform=node --format=esm --out-extension:.js=.mjs --outdir=./ index.ts node --prof --enable-source-maps $tmpdir/index.mjs node --prof-process --preprocess -j isolate*.log | npx speedscope - rm -rf $tmpdir ```Thanks!