simonpcouch/syrup

look into providing CPU usage

Closed this issue · 4 comments

From @topepo:

...can you get other process parameters (like cpu usage)?

This is definitely something I'd love to have available. From my understanding, the ps package doesn't include tools for measuring e.g. "% CPU" in Activity Monitor. If we can find a safe way to grab that information, we ought to.

That might look something like:

interval <- .5
times_t <- ps::ps_cpu_times()
Sys.sleep(interval)
times_t_plus_1 <- ps::ps_cpu_times()

user <- times_t_plus_1[["user"]] - times_t[["user"]]
system <- times_t_plus_1[["system"]] - times_t[["system"]]

(user + system) / interval
#> [1] 0.001063258

Might be a good place to note here that the full ps::ps_memory_full_info() output would be great to have, but I see an "Access denied" from the sesh process when I use it. Maybe worth poking at once more.

I'm especially interested in some sort of tool to collect data like that displayed in this book from Grant McDermott:

Screenshot 2024-06-18 at 9 46 06 AM

It'd be awesome to have per-CPU usage as well as just the usage for the core that the current R process is running on, as some parallelism approaches (i.e. threading from LightGBM and XGBoost) distribute within-model computations across all cores they have access to.

Closed via d324e8e!

EDIT: the pct_cpu values totally aren't right as-is--looking into it