From owner-freebsd-bugs@FreeBSD.ORG Tue Mar 31 17:58:52 2015 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CB4624DE for ; Tue, 31 Mar 2015 17:58:52 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B1DE2B5E for ; Tue, 31 Mar 2015 17:58:52 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.9/8.14.9) with ESMTP id t2VHwqhC036703 for ; Tue, 31 Mar 2015 17:58:52 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 199072] libmd inefficient read() calls Date: Tue, 31 Mar 2015 17:58:52 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 11.0-CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: kcwu@csie.org X-Bugzilla-Status: New X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2015 17:58:52 -0000 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@FreeBSD.org Reporter: kcwu@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.