From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vasilij Schneidermann Newsgroups: gmane.emacs.bugs Subject: bug#42998: 27.1; gnutls-symmetric-encrypt slow when providing cipher as symbol Date: Sun, 23 Aug 2020 18:43:30 +0200 Message-ID: <20200823164330.GA72308@odonien.localdomain> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="a8Wt8u1KmwUX3Y2C" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31949"; mail-complaints-to="usenet@ciao.gmane.io" To: 42998@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 23 18:44:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k9t6I-0008Ap-EV for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Aug 2020 18:44:10 +0200 Original-Received: from localhost ([::1]:33990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9t6H-0003g6-DB for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Aug 2020 12:44:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9t6A-0003fP-IM for bug-gnu-emacs@gnu.org; Sun, 23 Aug 2020 12:44:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k9t6A-0004KU-9d for bug-gnu-emacs@gnu.org; Sun, 23 Aug 2020 12:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k9t6A-0007LU-8N for bug-gnu-emacs@gnu.org; Sun, 23 Aug 2020 12:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vasilij Schneidermann Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Aug 2020 16:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 42998 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.159820102528179 (code B ref -1); Sun, 23 Aug 2020 16:44:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Aug 2020 16:43:45 +0000 Original-Received: from localhost ([127.0.0.1]:55008 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k9t5t-0007KR-7M for submit@debbugs.gnu.org; Sun, 23 Aug 2020 12:43:45 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:41890) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k9t5s-0007KG-0X for submit@debbugs.gnu.org; Sun, 23 Aug 2020 12:43:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9t5r-0003Zn-Pb for bug-gnu-emacs@gnu.org; Sun, 23 Aug 2020 12:43:43 -0400 Original-Received: from mout-p-201.mailbox.org ([2001:67c:2050::465:201]:29770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1k9t5p-0004IV-1q for bug-gnu-emacs@gnu.org; Sun, 23 Aug 2020 12:43:43 -0400 Original-Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4BZLft5P84zQlLD for ; Sun, 23 Aug 2020 18:43:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Original-Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id WDVKfDYGgvG4 for ; Sun, 23 Aug 2020 18:43:31 +0200 (CEST) Content-Disposition: inline X-Rspamd-Score: -6.58 / 15.00 / 15.00 X-Rspamd-Queue-Id: B0F265FE X-Rspamd-UID: 5de47e Received-SPF: pass client-ip=2001:67c:2050::465:201; envelope-from=mail@vasilij.de; helo=mout-p-201.mailbox.org X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:186065 Archived-At: --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I've recently debugged bad performance for a piece of code showing abysmal performance in its encryption loop. Compare the following benchmark results: (benchmark 10000 '(gnutls-symmetric-encrypt 'AES-128-CBC (make-string 16 0) (make-string 16 0) (make-string 16 0))) ;; =3D> "Elapsed time: 1.808647s (1.708427s in 124 GCs)" (benchmark 10000 '(gnutls-symmetric-encrypt 4 (make-string 16 0) (make-string 16 0) (make-string 16 0))) ;; =3D> "Elapsed time: 0.103690s (0.089148s in 6 GCs)" This seems to be the fault of how the cipher value is mapped to the cipher, if it's a symbol, the C code performs the equivalent of `(assoc cipher (gnutls-ciphers))`. Generating the cipher list over and over again seems like a waste of processing power. I'd consider either to document this behavior or making the mapping more efficient, for example by caching the cipher list instead of recomputing it over and over again. The latter would match the behavior as seen in other cryptographic library wrappers, for example the OpenSSL one in Ruby. In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22) of 2020-08-13 built on juergen Windowing system distributor 'The X.Org Foundation', version 11.0.12008000 System Description: Arch Linux Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Configured using: 'configure --prefix=3D/usr --sysconfdir=3D/etc --libexecdir=3D/usr/lib --localstatedir=3D/var --with-x-toolkit=3Dgtk3 --with-xft --with-wide-int --with-modules 'CFLAGS=3D-march=3Dx86-64 -mtune=3Dgeneric -O2 -pipe -fno-p= lt' CPPFLAGS=3D-D_FORTIFY_SOURCE=3D2 LDFLAGS=3D-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now' Configured features: XPM JPEG TIFF GIF PNG RSVG SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON PDUMPER LCMS2 GMP Important settings: value of $LC_MESSAGES:=20 value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs text-property-search time-date subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 45005 6273) (symbols 48 6004 1) (strings 32 15483 2032) (string-bytes 1 504714) (vectors 16 10090) (vector-slots 8 130067 10258) (floats 8 19 27) (intervals 56 196 0) (buffers 1000 11)) --a8Wt8u1KmwUX3Y2C Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEE0dAcySl3bqM8O17WFmfJg6zCifoFAl9CnKoACgkQFmfJg6zC ifpdWgf+Kjn7SHyzOey3lfixhPXEUr4ZBPBkeoX3YRO+dFPa9h9DhUdAvtCG2Tye aDLmOhdzkRtvzKGHzhvpU6YDz6tJcbR7jTAMeb8DzY2FH8AwbEcKvLrhq+jGOhKz JxROmgpK/7GWACfDabNuOrmvB7xlaiRyOQ7H7X/W0GoyWUZLrg/vbWPtvhipnRwV 3/S3xyqvVjqwKZcT0zYCLACivXj3qdN5JG1PisMtqKRyT6NdO6dMaN3yRmtKi6DZ /7CNd3JXgJafQhh7AVl9//R3XelTPHengAO8jTrX2Fr4Rgo2lr1Y8nXgM/+TkQjs QlfglAsZwZUoVIZhCUXlAlqOv7tnqg== =SxM9 -----END PGP SIGNATURE----- --a8Wt8u1KmwUX3Y2C--