yodaos-project/edge-monitor

perf: reduce the cpu usage of collecting smaps and top

yorkie opened this issue · 0 comments

At linux, the /proc/{pid}/smaps causes the kernel to do iterations for every process. This looks awful and unneeded in our use case.

Assuming that we have 10 processes to collect, to work on all the 10 processes by the proc file system, the kernel actually does 10+ iterations on the same memory struct.

See torvalds/linux:fs/proc/task_mmu.c for details.

To reduce the current high cpu of collecting smaps, we only do 1 iteration for all process collections.

/cc @lolBig @FeelyChau