e9c101edcb
Long ago, in a galaxy far away (when top was in charge of library FILL flgs) /proc/status was to be preferred over /proc/stat if a field could be satisfied by both. This was done to avoid costly 64-bit math emulation in a 32-bit application due to 'unsigned long long' data. Well it's time to acknowledge the prevalence of 64-bit platforms. And in such an environment the cost picture has shifted significantly. It now costs 14 times (wow) as much to access /proc/status compared to /proc/stat. In other words, even with '%llu' variables, a sscanf() call in stat2proc() beats the pants off that home brew gperf based hashing employed by the status2proc() guy. In fact, status2proc incurs higher costs than found in the most expensive aspect of top's forest view option. Here's a gprof extract to illustrate the costs. It was produced with an rcfile requiring fields from both the /proc/stat & /proc/status pseudo files (among others). There were 5000 iterations in each of 4 separate gprof runs subsequently merged into 1 gmon.sum for analysis. % self self time seconds calls us/call name ----- ------- ------- ------- ----------- 28.65 4.10 4689423 0.87 status2proc 26.14 3.74 40000 93.50 forest_adds ... 01.96 0.28 4689427 0.06 stat2proc [ since forest_adds is recursive, the calls value is ] [ the non-recursive #, its 'call graph' shows totals ] Anyway, now that such cost is known this patch becomes what is euphemistically known as the usual no-brainer. [ jeeze, was it really this long between profilings? ] Signed-off-by: Jim Warner <james.warner@comcast.net> |
||
---|---|---|
.. | ||
.gitignore | ||
alloc.c | ||
alloc.h | ||
COPYING | ||
devname.c | ||
devname.h | ||
diskstats.c | ||
diskstats.h | ||
escape.c | ||
escape.h | ||
libprocps.pc.in | ||
libprocps.sym | ||
meminfo.c | ||
meminfo.h | ||
namespace.c | ||
namespace.h | ||
openproc.3 | ||
pids.c | ||
pids.h | ||
procps-private.h | ||
procps.h | ||
pwcache.c | ||
pwcache.h | ||
readproc.3 | ||
readproc.c | ||
readproc.h | ||
readproctab.3 | ||
slabinfo.c | ||
slabinfo.h | ||
stat.c | ||
stat.h | ||
sysinfo.c | ||
sysinfo.h | ||
test_namespace.c | ||
test_pids.c | ||
test_sysinfo.c | ||
test_uptime.c | ||
test_version.c | ||
uptime.c | ||
uptime.h | ||
version.c | ||
version.h | ||
vmstat.c | ||
vmstat.h | ||
wchan.c | ||
wchan.h | ||
xtra-procps-debug.h |