[Bug 199072] libmd inefficient read() calls
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Tue Mar 31 17:58:52 UTC 2015
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=199072
Bug ID: 199072
Summary: libmd inefficient read() calls
Product: Base System
Version: 11.0-CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: bin
Assignee: freebsd-bugs at FreeBSD.org
Reporter: kcwu at csie.org
src/lib/libmd/mdXhl.c
MDXFileChunk(const char *filename, char *buf, off_t ofs, off_t len)
{
unsigned char buffer[BUFSIZ];
where BUFSIZE is 1024 from stdio.h
This will make lots of read(2) syscalls. All utilities depend on libmd,
including md5(1) and sha256(1), are affected.
==============
For example, on my system, (file content is already cached in ram)
$ du -h file.bin
4.9G file.bin
$ time md5 file.bin
MD5 (file.bin) = 422bb7e6759dee9dd1af940f9d9db5ab
real 0m31.848s
user 0m11.500s
sys 0m19.526s
Notice that 19.526s spend in sys.
You could also verify the read size is 1024 using truss(1)
$ truss md5 file.bin
...
read(3,"^3fEiRA\M^S\^]\M-Rf\M-7\M-E\M-g"...,1024) = 1024 (0x400)
...
==============
If modified buffer[] to larger, say 1MB, md5(1) becomes much faster.
$ time md5 file.bin
MD5 (file.bin) = 422bb7e6759dee9dd1af940f9d9db5ab
real 0m14.369s
user 0m11.220s
sys 0m1.933s
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list