-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose CPU and memory usage on per-component execution spans #2933
Comments
Relevant use case https://cloud-native.slack.com/archives/C06PC7JA1EE/p1732304052003759 |
Instead of CPU time what would be even better is CPU cycles. Cycles is more accurate as a CPU can have efficiency cores and performance cores. They can be in a boost mode or a low power mode. Cycles is actual usage where time has too many variables. |
We might consider making the calculation of this metric pluggable. There isn't really any one great metric to represent "CPU usage" across different applications and platforms; lots of performance counters are manufacturer-specific and require careful interpretation to be useful for decision making anyway. Further, there will be some (small, probably, but dependent on the exact metric) performance overhead to cpu measurements and we would generally need to track them on every context switch to/from a guest application to account for host overhead and async task switching. |
Making it pluggable would be cool. At what level do you imagine it being pluggable? Compile Spin with special feature flags? Pass a flag to spin when running it to turn it on? Something else? |
I was thinking of something similar to trait CpuUsageHook {
// Called every time the guest is entered; implementations might record
// some baseline counter value here.
fn enter_guest(&mut self);
// Called every time the guest exits. Implementations are expected to
// record the "usage" measured since the last call to `enter_guest`.
fn exit_guest(&mut self) -> u64;
}
spin_core_config.set_cpu_usage_hook(MyIntelCpuPerformanceCounterUsageHook); |
It would be nice if we could see the amount of memory and CPU that was used when a component is executed.
I believe exposing CPU time requires a CallHook which means we'll probably want to put it behind a feature flag or benchmark it to make sure it doesn't regress performance.
The text was updated successfully, but these errors were encountered: