]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lsfd: optimize maps use
authorKarel Zak <kzak@redhat.com>
Thu, 30 Sep 2021 08:42:02 +0000 (10:42 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 6 Oct 2021 09:01:54 +0000 (11:01 +0200)
commit5593f1d147d4d72f2f0da47af4222b38168a157b
tree82e856b5a43d9fb17e83baa8080660e198db32f7
parent6230d4118d7ac304fc76ec5b122a70e61ad26aa0
lsfd: optimize maps use

The /proc/#/maps file usually contains the same file more than once.
This patch tries to reuse previous file to reduce number of stat()
calls, see "strace --summary-only" output below, the syscall is reduce
in 50%.

old version:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 55.57    0.118708           2     50756      5414 newfstatat

new version:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 39.17    0.058501           2     24436      5382 newfstatat

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsfd.c