This is a Rust program compiled to wasm32, running in Chrome.
My program forks of multiple webworkers.
Is there a way to, in Rust/wasm32, implement something like 'top' ?
I.e. I want to get a list of all the webworkers (that my process started).
For each webworker, I want to get an approximate cpu usage + memory usage.
Solutions that involves "help" from the webworker (i.e. webworkers self report) are fine too. I'm just not sure if this is even possible at all.
The only way I can think of that works without a native program running outside of the browser would be to have each web worker get timestamps of the exact position where they receive some work and where they have finished the work and then report this to the main thread, which can then compute how much time each web worker spent. You would need to take special care with web workers getting blocked though as this method will report them as still consuming cpu. For memory usage, if you are a pure webassembly workload you can get very close by looking at the size of the linear memory, for js workloads I don't think you can get the memory usage from js.