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?G=C3=B6ran?= Weinholt Newsgroups: gmane.lisp.guile.devel Subject: Re: SHA256 performance with Guile 2.2 vs. Guile 3.0 Date: Sun, 05 Jan 2020 15:28:50 +0100 Message-ID: <87blric6zh.fsf@teapot.weinholt.se> References: <874kxcnlh8.fsf@inria.fr> <87sgkwm4uv.fsf@gnu.org> <87h81b7bym.fsf@teapot.weinholt.se> <87ftgurkfv.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="112964"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: Andy Wingo , Ludovic =?utf-8?Q?Court=C3=A8s?= , guile-devel@gnu.org To: Arne Babenhauserheide Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Jan 05 15:35:55 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 1io70T-000T7V-NO for guile-devel@m.gmane.org; Sun, 05 Jan 2020 15:35:53 +0100 Original-Received: from localhost ([::1]:42646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io70M-0001Yk-NU for guile-devel@m.gmane.org; Sun, 05 Jan 2020 09:35:46 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41638) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io701-0001X8-6F for guile-devel@gnu.org; Sun, 05 Jan 2020 09:35:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io6zy-0000bR-74 for guile-devel@gnu.org; Sun, 05 Jan 2020 09:35:23 -0500 Original-Received: from iustitia.weinholt.se ([2a02:28f0:0:a::7dce:e5a8]:35410) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1io6zw-0000XS-6t; Sun, 05 Jan 2020 09:35:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=weinholt.se ; s=iustitia2012; h=Content-Transfer-Encoding:Content-Type:MIME-Version: Message-ID:In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=mOBPHviJ59I+kCdIADD5D7tgUicCgt2mGtnmHMFDfYw=; b=emwhuCoeScZTIkVvZGr2c+dhzl h7FdXf91aflUhsnKLA3uoUPYmH1L08N7Td00hZ5nt69liSCnx3q7d1kUjhh7gtnGYKxUVzow5LnAi lTNPeGB9wjEk0eVkPPdW3igF6BoQ+EtqAGodRx8TXh1vJq2wotHJj2RkqALXI7EBa3C82gcjxmxS7 GG2+xnuRR/r00KPhTyL4SVgZjT6GoALW0zvScyny6nDy68xMDnuOHTjKyaPFmqGRJBtyVSGKkRgl+ U4x3WIe4ispVe0kjjCtR0ct0fNOYyztUKYfcBhIIeySRmpHALuZii0gDekIFWZpJj4SFyMliLIiFv zGZVpf8A==; Original-Received: from uucp by iustitia.weinholt.se with local-bsmtp (Exim 4.89) (envelope-from ) id 1io6zi-0001b0-5e; Sun, 05 Jan 2020 15:35:06 +0100 Original-Received: from weinholt by teapot with local (Exim 4.93-RC5) (envelope-from ) id 1io6te-0002Ct-IK; Sun, 05 Jan 2020 15:28:50 +0100 X-Hashcash: 1:20:200105:wingo@igalia.com::KkY0jTIk35cLOtoW:05elQ X-Hashcash: 1:20:200105:guile-devel@gnu.org::eCAAbO/DZ+3Ur/8E:00000000000000000000000000000000000000000062JH X-Hashcash: 1:20:200105:ludo@gnu.org::ZrBl3AM/BFBGky6o:000006Guf X-Hashcash: 1:20:200105:arne_bab@web.de::ADn4SZy0OsjyJVXv:00DTvK In-Reply-To: <87ftgurkfv.fsf@web.de> (Arne Babenhauserheide's message of "Sat, 04 Jan 2020 22:39:41 +0100") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a02:28f0:0:a::7dce:e5a8 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:20224 Archived-At: Arne Babenhauserheide writes: > G=C3=B6ran Weinholt writes: >> I've pushed a Guile-specific version of (hashing fixnums) that inlines >> the generic arithmetic procedures. This and some other small changes >> improved the runtime: >> >> clock utime stime cutime cstime gctime >> before: >> 2.2.6 31.06 32.61 0.03 0.00 0.00 1.38 >> 2.9.8 15.55 16.23 0.01 0.00 0.00 1.19 >> after: >> 2.2.6 2.95 3.01 0.00 0.00 0.00 0.10 >> 2.9.8 1.98 1.99 0.00 0.00 0.00 0.08 >> >> That's about 100 times slower than sha256sum from coreutils. You might >> get some more performance out of it by unrolling the loop in >> sha-256-transform!. > > I=E2=80=99d like to highlight the understatement: The new version is about > factor 10 faster on 2.2.6 and factor 8 faster on 2.9.8 (and the new > version on Guile 2.9.8 is factor 15 faster than the old version with the > old Guile). > > That=E2=80=99s an awesome speedup! > > (can you show the change/patch that did this? Sidenote: It would be > great to have a list of performance hints for Guile) The commit is here: https://github.com/weinholt/hashing/commit/eb28080180b5fdfb6ffc74f8cdf2c1a7= 823ef0cb The relevant changes are: * The define-fx macro previously returned: #'(define name (if (> (fixnum-width) bit-width) fxname bitwise-name)) This was bad for three reasons: Guile does not do constant folding on (fixnum-width); in Guile the fixnum procedures are slower than the generic procedures; and Guile 2.2 did not inline those defines. It now returns: #'(define-syntax name (identifier-syntax bitwise-name)) So the generic procedures like +, bitwise-and, etc are used instead of fx+ and fxand. The use of define-syntax and identifier-syntax is basically manual inlining for the benefit of Guile 2.2. * I replaced some instances of fixnum operations with the ones from (hashing fixnums), which benefit from the above. * I changed some comparisons with constant fixnums to use eqv? instead of fx=3D?, e.g. (eqv? i 8) instead of (fx=3D? i 8). This is commonly faster, not only in Guile, because in implementations with immediate fixnums it can be done with only a simple compare + branch. I don't know if Guile takes advantage of this fact, but it's still faster than fx=3D?. Regards, --=20 G=C3=B6ran Weinholt | https://weinholt.se/ Debian developer | 73 de SA6CJK