]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libblkid: use mmap() rather than read()
authorKarel Zak <kzak@redhat.com>
Tue, 22 Sep 2015 13:37:26 +0000 (15:37 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 24 Sep 2015 09:10:09 +0000 (11:10 +0200)
commita674a0ab03660b1df777e69436b2dc832b6f8681
tree8942144d82f40e6b922810eed11310492f647e5c
parent9325a8be9e55cc01d9f580e14dd2193829245183
libblkid: use mmap() rather than read()

diff between
perf stat -e 'syscalls:sys_enter_*'
for old and new version:

-                35      syscalls:sys_enter_lseek
-                38      syscalls:sys_enter_read
+                 3      syscalls:sys_enter_read
...
-                19      syscalls:sys_enter_mmap
+                17      syscalls:sys_enter_mmap

-       0.001083084 seconds time elapsed
+       0.000751722 seconds time elapsed

The patch dramatically reduces malloc()+seek()+read() operations in
libblkid. The code mmaps ~2MiB of the begin and the end of the device
and it moves buffers management to kernel.

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/blkidP.h
libblkid/src/init.c
libblkid/src/probe.c