]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
md5sum, sha*sum: use libcrypto where available
authorPádraig Brady <P@draigBrady.com>
Tue, 3 Dec 2013 03:51:52 +0000 (03:51 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 4 Dec 2013 13:18:56 +0000 (13:18 +0000)
libcrypto is generally available and has well optimized
crypto hash routines particular to various systems.
For example, testing sha1sum with openssl-1.0.0j
on an i3-2310M, gives a performance boost of about 40%:

$ time sha1sum.old --tag ~/test.iso
SHA1 (/home/padraig/test.iso) = 3c27f7ed01965fd2b89e22128fd62dc51a3bef30
real    0m4.692s
user    0m4.499s
sys     0m0.162s

$ time sha1sum.new --tag ~/test.iso
SHA1 (/home/padraig/test.iso) = 3c27f7ed01965fd2b89e22128fd62dc51a3bef30
real    0m2.685s
user    0m2.512s
sys     0m0.170s

* configure.ac: By default, enable use of libcrypto if available.
* src/local.mk: Link with libcrypto.
* NEWS: Mention the md5sum and sha*sum improvements.

NEWS
configure.ac
src/local.mk

diff --git a/NEWS b/NEWS
index 520e94669e93be9ca891dec96ceab631a4f23899..e0cd5400c879b1672112055e05ace443e69ee845 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -116,6 +116,11 @@ GNU coreutils NEWS                                    -*- outline -*-
 
   base64 encoding throughput for bulk data is increased by about 60%.
 
+  md5sum uses libcrypto hash routines where available to potentially
+  get better performance through using more system specific code.
+  sha1sum for example has improved throughput by 40% on an i3-2310M.
+  This also affects sha1sum, sha224sum, sha256sum, sha384sum and sha512sum.
+
   stat and tail work better with EFIVARFS, EXOFS, F2FS, SNFS and UBIFS.
   stat -f --format=%T now reports the file system type, and tail -f now uses
   inotify for files on those file systems, rather than the default (for unknown
index 8a3ac48a01d9149cfae12d11d9a857640c26a3f1..16b6c35b101275cbbe21d49b5cd4d5aaf26538c1 100644 (file)
@@ -50,6 +50,17 @@ m4_syscmd([test "${GNULIB_POSIXCHECK+set}" = set])
 m4_if(m4_sysval, [0], [], [dnl
 gl_ASSERT_NO_GNULIB_POSIXCHECK])
 
+dnl Enable use of libcrypto if available.
+dnl Note we could do this as follows:
+dnl   AS_VAR_SET_IF([with_openssl], [], [with_openssl=optional])
+dnl However that would not document the coreutils adjusted default,
+dnl so we add another --with-openssl description just to document that
+AC_ARG_WITH([openssl],
+  [AC_HELP_STRING([--with-openssl],
+    [The coreutils default is: --with-openssl=optional])],
+  [],
+  [with_openssl=optional])
+
 AC_PROG_CC_STDC
 AM_PROG_CC_C_O
 AC_PROG_CPP
index 1315e1103bdc4a3bc1a85fda6a41d0222c5c3ba2..fe80f41c1575d1beba758be67c137dfcd18f927e 100644 (file)
@@ -293,6 +293,15 @@ src_stdbuf_LDADD += $(LIBICONV)
 src_timeout_LDADD += $(LIBICONV)
 src_truncate_LDADD += $(LIBICONV)
 
+# for libcrypto hash routines
+src_md5sum_LDADD += $(LIB_CRYPTO)
+src_sort_LDADD += $(LIB_CRYPTO)
+src_sha1sum_LDADD += $(LIB_CRYPTO)
+src_sha224sum_LDADD += $(LIB_CRYPTO)
+src_sha256sum_LDADD += $(LIB_CRYPTO)
+src_sha384sum_LDADD += $(LIB_CRYPTO)
+src_sha512sum_LDADD += $(LIB_CRYPTO)
+
 # for canon_host
 src_pinky_LDADD += $(GETADDRINFO_LIB)
 src_who_LDADD += $(GETADDRINFO_LIB)