From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.devel Subject: Re: Execution speed Date: Sun, 19 Mar 2017 15:09:05 -0400 Message-ID: <87lgs13wz2.fsf@users.sourceforge.net> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1489950479 8577 195.159.176.226 (19 Mar 2017 19:07:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 19 Mar 2017 19:07:59 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 19 20:07:54 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpgBC-0001M8-Cq for ged-emacs-devel@m.gmane.org; Sun, 19 Mar 2017 20:07:50 +0100 Original-Received: from localhost ([::1]:57782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpgBI-00022F-FH for ged-emacs-devel@m.gmane.org; Sun, 19 Mar 2017 15:07:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpgBC-000220-IZ for emacs-devel@gnu.org; Sun, 19 Mar 2017 15:07:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cpgB9-0000DX-4M for emacs-devel@gnu.org; Sun, 19 Mar 2017 15:07:50 -0400 Original-Received: from mail-it0-x22e.google.com ([2607:f8b0:4001:c0b::22e]:38690) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cpgB8-0000D6-Ts for emacs-devel@gnu.org; Sun, 19 Mar 2017 15:07:47 -0400 Original-Received: by mail-it0-x22e.google.com with SMTP id y18so12390242itc.1 for ; Sun, 19 Mar 2017 12:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :mime-version; bh=ntivjQsq43DYXPk4IEaxIfGAN+lblJGKKC26f1gYFIM=; b=uTg6X9OVjsvCuH1Wd2N/ICv2tHGcfcahbr6n+6BWYPpS7XITdbbHLY47N3jBGScxmB fvZjXlZQvFhkN5TrgSe5eI6H3WocKET1+mu1TnPQfezComWdBjzHsmAa/zhP4HP4YArz T2ChiYRuVp5rBFPHfjScb2A5we6njehxwCluaWM0indgOmNSMabIia6j6V3EPHas/bXY HEygvUXY3kl2l+etXryJ6H+FBkWACWWj+kle7nNEwa91cDuORecbIAF5GkcLiqFSJ22e uIbl2smTA38yqAJU7bPL103fvfggc2VD8eKXYRWyeckfJz7+PRrS8zs+qAB2tnnboqh6 3/Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:mime-version; bh=ntivjQsq43DYXPk4IEaxIfGAN+lblJGKKC26f1gYFIM=; b=jTwJRG5b/2vBAqLYpisgMiOXBQGSOfs9gEgBao5ptjB+BwjX9s4m3IxlcETN1MsuYF 0OMXpI8ZYjXK/CweAQaqH9aGqbZ63FMftgEAVTJTOet5Q9hOrj9i0VXUoJMRwgqipWjw FR8lnrYRM/Tm06jr6tfVADu5jfz6JHq5/31Mmtmmt/5M7MWHHNPIoxq0bxB3YD7PqfQl Bst7ZdlQhv2Apa/hz3hPlbmmPQNFcIr5QIvdDDDIG4r5MfoObdASs6bN/yMOSHNW6ZcG oTzQTyH4KWQepB2GBTPcJNoL3hBfCOdUdwlmQYxDYd6gk9WtknpfW8PQ2/zIYf+b/h0Y bcHw== X-Gm-Message-State: AFeK/H3ZOAsvN40MJMCpEAtDeDnUNIKNRZjhoO1eXCQxLehOzSUUwYWea/HNfiWPC9GFbQ== X-Received: by 10.107.58.131 with SMTP id h125mr26879861ioa.37.1489950466298; Sun, 19 Mar 2017 12:07:46 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id 62sm6050441itl.1.2017.03.19.12.07.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 19 Mar 2017 12:07:45 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Sun, 19 Mar 2017 11:12:59 -0400") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4001:c0b::22e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:213163 Archived-At: --=-=-= Content-Type: text/plain On Sun, Mar 19, 2017 at 11:12 AM, Stefan Monnier wrote: > the other one is my locally built&hacked version with debugging > assertions and stuff. Is that the one that sets lexical-binding always? According to my measurements, the iterative case is slower on Emacs 25 when using dynamic binding. With lexical binding, the recursive case is always slower. (Note the measurements below are using unoptimized -O0 builds, with extra checking enabled) GNU Emacs 24.5.5 (x86_64-unknown-linux-gnu, X toolkit) of 2017-02-12 on zony | DYNAMIC | interpreted | compiled | |-----------+-------------+----------| | recursive | 7.64s | 5.61s | | iterative | 7.91s | 4.24s | | LEXICAL | interpreted | compiled | |-----------+----------------------------+------------------------| | recursive | 21.82s (12.20s in 470 GCs) | 4.73s (0.15s in 6 GCs) | | iterative | 8.87s (0.54s in 21 GCs) | 3.14s (0.15s in 6 GCs) | GNU Emacs 25.2.6 (x86_64-unknown-linux-gnu, X toolkit) of 2017-03-01 | DYNAMIC | interpreted | compiled | |-----------+-------------+----------| | recursive | 10.58s | 6.39s | | iterative | 14.05s | 6.72s | | LEXICAL | interpreted | compiled | |-----------+----------------------------+------------------------| | recursive | 35.44s (20.56s in 448 GCs) | 4.35s (0.28s in 6 GCs) | | iterative | 13.20s ( 0.92s in 20 GCs) | 2.96s (0.23s in 5 GCs) | --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=gcd-benchmark-dynamic.el Content-Transfer-Encoding: quoted-printable Content-Description: benchmarking code (defun gcdi-interpreted-dynamic (a b) (let ((x a) (y b) r) (while (not (zerop y)) (setq r (mod x y) x y y r)) x)) (defun gcdi-compiled-dynamic (a b) (let ((x a) (y b) r) (while (not (zerop y)) (setq r (mod x y) x y y r)) x)) (byte-compile 'gcdi-compiled-dynamic) (defun gcdr-interpreted-dynamic (a b) (if (zerop b) a (gcdr-interpreted-dynamic b (mod a b)))) (defun gcdr-compiled-dynamic (a b) (if (zerop b) a (gcdr-compiled-dynamic b (mod a b)))) (byte-compile 'gcdr-compiled-dynamic) (defun benchmark-str (result) (if (zerop (nth 1 result)) (format "%.2fs" (car result)) (format "%.2fs (%.2fs in %d GCs)" (car result) (nth 2 result) (nth 1 result)))) (defun gcd-dynamic-benchmarks () (interactive) (insert "|DYNAMIC | interpreted | compiled|\n") (insert "|-\n") (insert "|recursive|") (insert (benchmark-str (benchmark-run 80000 (gcdr-interpreted-dynamic 14472334024676221 8944394323791464))= )) (insert "|") (insert (benchmark-str (benchmark-run-compiled 80000 (gcdr-compiled-dynamic 14472334024676221 8944394323791464)))) (insert "|\n") (insert "|iterative|") (insert (benchmark-str (benchmark-run 80000 (gcdi-interpreted-dynamic 14472334024676221 8944394323791464))= )) (insert "|") (insert (benchmark-str (benchmark-run-compiled 80000 (gcdi-compiled-dynamic 14472334024676221 8944394323791464)))) (insert "|\n")) --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=gcd-benchmark-lexical.el Content-Transfer-Encoding: quoted-printable Content-Description: benchmarking lexical code ;;; -*- lexical-binding: t -*- (defun gcdi-interpreted-lexical (a b) (let ((x a) (y b) r) (while (not (zerop y)) (setq r (mod x y) x y y r)) x)) (defun gcdi-compiled-lexical (a b) (let ((x a) (y b) r) (while (not (zerop y)) (setq r (mod x y) x y y r)) x)) (byte-compile 'gcdi-compiled-lexical) (defun gcdr-interpreted-lexical (a b) (if (zerop b) a (gcdr-interpreted-lexical b (mod a b)))) (defun gcdr-compiled-lexical (a b) (if (zerop b) a (gcdr-compiled-lexical b (mod a b)))) (byte-compile 'gcdr-compiled-lexical) (defun benchmark-str (result) (if (zerop (nth 1 result)) (format "%.2fs" (car result)) (format "%.2fs (%.2fs in %d GCs)" (car result) (nth 2 result) (nth 1 result)))) (defun gcd-lexical-benchmarks () (interactive) (insert "|LEXICAL | interpreted | compiled|\n") (insert "|-\n") (insert "|recursive|") (insert (benchmark-str (benchmark-run 80000 (gcdr-interpreted-lexical 14472334024676221 8944394323791464))= )) (insert "|") (insert (benchmark-str (benchmark-run-compiled 80000 (gcdr-compiled-lexical 14472334024676221 8944394323791464)))) (insert "|\n") (insert "|iterative|") (insert (benchmark-str (benchmark-run 80000 (gcdi-interpreted-lexical 14472334024676221 8944394323791464))= )) (insert "|") (insert (benchmark-str (benchmark-run-compiled 80000 (gcdi-compiled-lexical 14472334024676221 8944394323791464)))) (insert "|\n")) --=-=-=--