Skip to content

Thread to monitor the kernel usage (CPU, Memory...) #912

@echarles

Description

@echarles

While implementing a jupyterlab extension to monitor the kernel usage (https://github.com/Quansight/jupyterlab-kernel-usage), a few PRs have been merged to use psutil to return Memory, CPU usage of the machine and the kernel processes.

This has worked great for most of the metrics, but we hit now an issue for the kernel CPU reported on Quansight/jupyterlab-kernel-usage#11. psutil returns the CPU based on the last call, so it looks like everytime we ask the CPU via the kernel websocket, it return zero as psutil considers it is the first time the request is made, see info on:

Please note that similar issue is reported on the jupyter-resource-usage extension (which monitors the server usage, not the kernel usage) jupyter-server/jupyter-resource-usage#107

A solution would be to maintain a separated thread that would be responsible to return that CPU in a correct way based on psutil.

What would be the impact to create such as separated thread? What are the already existing threads? Does it sound like a reasonable approach? Any other idea?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions