Stream: git-wasmtime

Topic: wasmtime / issue #7667 Measure thread-local CPU usage in ...


view this post on Zulip Wasmtime GitHub notifications bot (Dec 09 2023 at 00:50):

jameysharp opened issue #7667:

Feature

We record the wall-clock time when each call-stack sample was taken in the guest profiler, but the Firefox profiler format also allows us to record how much CPU time was used since the last sample.

Benefit

This should change the profile viewer’s output format to offer total time in various places, not just number of samples. That's generally easier for people to understand.

Implementation

On POSIX platforms, the clock to use is rustix::time::clock_gettime(ClockId::ThreadCPUTime). I don't know how to do this on Windows.

In GuestProfiler::sample, the call to self.profile.add_sample currently passes CpuDelta::ZERO and should instead pass the difference between two queries of the above clock.

I'm not sure if this would work correctly for an embedder who time-slices between different guests on the same OS thread. I don't know if we can detect when the current guest is swapped out or back in without some kind of magic attached to the current wasmtime-fibers code for swapping thread-local storage.

Alternatives

The profiler is usable without this CPU time metric.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 09 2023 at 00:51):

jameysharp added the enhancement label to Issue #7667.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 09 2023 at 00:51):

jameysharp added the wasmtime label to Issue #7667.


Last updated: Nov 22 2024 at 16:03 UTC