]> granicus.if.org Git - procps-ng/commit
top: snapshot /proc/stat reads to minimize distortions
authorJim Warner <james.warner@comcast.net>
Sun, 14 Apr 2013 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Tue, 23 Apr 2013 22:29:22 +0000 (08:29 +1000)
commitd16fd8e4629cc4ea2cfc0954762079cbdaa544d5
tree33875448d71be48a7594013726e15dfbfa907b83
parent3ac09447e5d4ca217549c4ca3154a4a5805e7d6e
top: snapshot /proc/stat reads to minimize distortions

Almost forever, top has been accessing the /proc/stat/
directory one line at a time until either smp_num_cpus
was reached or (more recently) Screen_rows is reached.

When NUMA/Nodes support is enabled screen rows will no
longer serve as a limit because all cpus must be read.

With this commit, the entire /proc/stat/ directory can
be read at once so all statistics will be frozen. Thus
individual cpus will no longer keep "ticing" until top
gets around to accessing them via some separate fgets.

The distortion this commit eliminates was quite easily
seen when comparing old/new tops using: individual cpu
stats vs. cpu summary; a healthy delay interval of 3-5
seconds; manually synchronized update cycles (the hard
part); some system loading (maybe another top at -d0).

Additionally, this patch eliminates some long standing
unnecessary initialization made possible because of an
allocation via calloc. If some parts are never touched
by sscanf due to a kernel version, it's unnecessary to
repeatedly re-initialize those portions to zero again.

Reference(s):
. numa extensions added
commit 8d989c68c068541a814bf0d2340ac9b0373f24b5
. useless initialization evolution (old to new)
commit e54c8239b1c46cf7b99dd6120c9090303fa969c8
commit 9278134e49b6bf4d6e05c40f63cc6d6d6936e01b
commit fd62123562c2b71f292d3d3ee1a085709048b11a
commit f348575edc915db9df89acfb3f292920726ffe9a

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c