r-lib / ps

R package to query, list, manipulate system processes
https://ps.r-lib.org/
Other
77 stars 19 forks source link

More ps_handle class methods #24

Open gaborcsardi opened 6 years ago

gaborcsardi commented 6 years ago
mike-lawrence commented 3 years ago

+1 for set_cpu_affinity! Just needs taskset on Linux, but dunno about other OSs

gaborcsardi commented 3 years ago

Calling external commands is not great in R, and small Docker containers might not have taskset. But there is an easy API for this on Linux: https://linux.die.net/man/2/sched_getaffinity

There is also API for it on Windows: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprocessaffinitymask

It seems impossible on macOS, though.

brianmsm commented 2 years ago

I was just looking for the memory_full_info function. I understand it's still in the process of implementation, right?

gaborcsardi commented 2 years ago

@brianmsm Well, these are things I might implement in the future, or things I am happy to get help with.

What do you need from memory_full_info()? There is ps_memory_info() with some basic information:

❯ ps::ps_memory_info()
         rss          vms      pfaults      pageins
    81592320 419098476544         5515           42
brianmsm commented 2 years ago

Well, following the psutil documentation in python, the memory_full_info() function allows access to uss (Unique Set Size), pss (Proportional Set Size) and swap information. In my case I am very interested in getting the swap memory information used in a particular process.

gaborcsardi commented 2 years ago

@brianmsm Happening here: https://github.com/r-lib/ps/pull/122, Linux seems to be working well.

brianmsm commented 2 years ago

Great! Thank you very much, I'll be waiting for you to join the main branch :D

gaborcsardi commented 2 years ago

CPU affinity happening here, FYI: https://github.com/r-lib/ps/pull/123