fastly / js-compute-runtime

JavaScript SDK and runtime for building Fastly Compute applications
https://developer.fastly.com/learning/compute/javascript/
Apache License 2.0
200 stars 28 forks source link

Provide option to capture performance profile #49

Open voxpelli opened 3 years ago

voxpelli commented 3 years ago

When using Firefox one can profile the javascript running in SpiderMonkey and get a flame chart either directly in there or by exporting the data and visualizing it in eg. https://github.com/jlfwong/speedscope

To enable understanding in how the WASM-compiled SpiderMonkey executes ones code and to more aggressively profile that code it would be fabulous to be able to export such profiling data from it as well, either by setting a flag when compiling or through a similar mechanism as enableDebugLogging().

I've tried digging into the code of SpiderMonkey/Firefox to understand how to achieve this, but unfortunately its a bit outside of my expertise so I haven't found out how, hence opening an issue rather than a PR.

tschneidereit commented 3 years ago

I very much agree that having this would be great! However, I haven't looked into what it'd take to enable that, and fear that we won't be able to get to it in the foreseeable future, sadly :(

One thing that might be vaguely relevant is that I at one point created an experimental integration of memory usage stats reporting. See the various uses of MEM_STATS in the main runtime source file. I'm not at all sure if perf stats are even remotely similar to memory stats, but should they be, this might provide some pointers.