From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Newsgroups: gmane.lisp.guile.devel Subject: SHA256 performance with Guile 2.2 vs. Guile 3.0 Date: Sat, 04 Jan 2020 00:55:47 +0100 Message-ID: <874kxcnlh8.fsf@inria.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="229168"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: Andy Wingo To: Guile Devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Jan 04 00:55:58 2020 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1inWnM-000xOT-Go for guile-devel@m.gmane.org; Sat, 04 Jan 2020 00:55:56 +0100 Original-Received: from localhost ([::1]:58044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1inWnL-0006NB-90 for guile-devel@m.gmane.org; Fri, 03 Jan 2020 18:55:55 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50125) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1inWnG-0006N4-Sh for guile-devel@gnu.org; Fri, 03 Jan 2020 18:55:52 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:44172) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1inWnG-0006jO-7I; Fri, 03 Jan 2020 18:55:50 -0500 Original-Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=59340 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1inWnF-0001iT-NA; Fri, 03 Jan 2020 18:55:50 -0500 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 15 =?utf-8?Q?Niv=C3=B4se?= an 228 de la =?utf-8?Q?R?= =?utf-8?Q?=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:20209 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Guilers! G=C3=B6ran Weinholt wrote a pure-Scheme (R6RS) implementation of common cryptographic hash functions: https://github.com/weinholt/hashing I thought this would make a useful benchmark (and probably favorable to JIT because it=E2=80=99s one hot loop), so here goes (computing the SHA256 = hash of =E2=80=98guile-2.2.6.tar.xz=E2=80=99 with the code below, compiled with = -O2, Guile 2.2.6 vs. 2.9.8): --8<---------------cut here---------------start------------->8--- ludo@ribbon ~/src/guix$ ./pre-inst-env guix environment --pure --ad-hoc gui= le guile-hashing -- guile ~/tmp/sha256.scm ;;; (hash "b33576331465a60b003573541bf3b1c205936a16c407bc69f8419a527bf5c988= ") clock utime stime cutime cstime gctime 135.07 164.13 0.52 0.00 0.00 42.14 ludo@ribbon ~/src/guix$ ./pre-inst-env guix environment --pure --ad-hoc gui= le-next guile3.0-hashing -- guile ~/tmp/sha256.scm ;;; (hash "b33576331465a60b003573541bf3b1c205936a16c407bc69f8419a527bf5c988= ") clock utime stime cutime cstime gctime 65.17 89.75 0.45 0.00 0.00 35.63 --8<---------------cut here---------------end--------------->8--- Guile 3 is twice as fast! No difference if we force =E2=80=98-O3=E2=80=99. Still far from the libgcrypt implementation in C + asm, but hey! --8<---------------cut here---------------start------------->8--- ludo@ribbon ~/src/guix$ time guix hash -f hex "/gnu/store/zfp7d4wr5hbl5lrnz= s8c15bsc3ygq74g-guile-2.2.6.tar.xz" b33576331465a60b003573541bf3b1c205936a16c407bc69f8419a527bf5c988 real 0m0.097s user 0m0.093s sys 0m0.024s --8<---------------cut here---------------end--------------->8--- To be continued=E2=80=A6 Ludo=E2=80=99. --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=sha256.scm Content-Description: The code (use-modules (hashing sha-2) (rnrs bytevectors) (ice-9 binary-ports) (ice-9 match) (ice-9 time)) (define (port-sha256 port) ;; Return the SHA256 of the data read from PORT. (define bv (make-bytevector 65536)) (define hash (make-sha-256)) (let loop () (match (get-bytevector-n! port bv 0 (bytevector-length bv)) ((? eof-object?) (sha-256-finish! hash) hash) (n (sha-256-update! hash bv 0 n) (loop))))) (define (file-sha256 file) ;; Return the SHA256 of FILE. (call-with-input-file file port-sha256)) (time (pk 'hash (sha-256->string (file-sha256 "/gnu/store/zfp7d4wr5hbl5lrnzs8c15bsc3ygq74g-guile-2.2.6.tar.xz")))) --=-=-=--