cpu: calculate current CPU usage from delta instead of avg since boot#53
cpu: calculate current CPU usage from delta instead of avg since boot#53
Conversation
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I2088217f2c2924fa9200f43033bb92426a6a6964
|
A few Q's:
|
Allow rules to match on average CPU usage over a specified duration and enables detecting sustained load patterns rather than just instantaneous CPU usage. Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I9bea708d7ed5888a697e9a4ede7b8dfa6a6a6964
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I3385837946b5f4f19980b4bd5fe899696a6a6964
7d20abf to
0abb36f
Compare
No, it's no longer from boot because we're changing it;
I think the solution here is to sample at a fixed high frequency (like 100ms or 500ms) regardless of
You're right, I'll remove those. Addressed the rest of your comments. |
How much of a delta? I don't think we should have that, everyone should set the delta themselves.
Won't that be too intensive? Also sounds like a waste |
|
Do you have a better idea? |
|
The idea I had was traverse the Expression and collect all of the cpu-usage-since = "..." durations and sample with some fraction of that delta. We can use a derive Visitor crate to make this really easy and get the min usage-since Duration |
|
It does not seem like I'll be receiving any more meaningful comments, so I'm merging. The issue is fixed, nitpicks can wait. |
|
bro casually ignored the |
Fixes #51, at least partially. Did not yet implement time-delta measurements yet, but it is not exactly a part of the issue I was trying to fix. Will be implementing at a later date alongside a
--dry-runflag.This PR only introduces a new expression (
cpu-usage-since) for evaluating CPU usage over a specified time interval and refactors CPU usage calculation to be based on recent usage deltas rather than historical averages. The time expression is backed by the humantime crate, which allows for intuitive time formats. Also adds support for logging CPU usage history.Signed-off-by: NotAShelf raf@notashelf.dev
Change-Id: I2088217f2c2924fa9200f43033bb92426a6a6964