From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.devel Subject: Performance of lexical closures in interpreted code? (was Re: Execution speed) Date: Mon, 20 Mar 2017 23:36:49 +1300 Message-ID: References: <87lgs13wz2.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1490006267 29377 195.159.176.226 (20 Mar 2017 10:37:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 20 Mar 2017 10:37:47 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 20 11:37:43 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 1cpuh0-0006uy-JU for ged-emacs-devel@m.gmane.org; Mon, 20 Mar 2017 11:37:38 +0100 Original-Received: from localhost ([::1]:60201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpuh6-0007hK-Lu for ged-emacs-devel@m.gmane.org; Mon, 20 Mar 2017 06:37:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpugT-0007g2-AI for emacs-devel@gnu.org; Mon, 20 Mar 2017 06:37:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cpugO-0004p6-ET for emacs-devel@gnu.org; Mon, 20 Mar 2017 06:37:05 -0400 Original-Received: from [219.88.242.62] (port=49769 helo=mail.orcon.net.nz) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cpugN-0004oG-Tl for emacs-devel@gnu.org; Mon, 20 Mar 2017 06:37:00 -0400 Original-Received: from [192.168.20.100] ([150.107.175.236]) (authenticated bits=0) by mail.orcon.net.nz (8.14.3/8.14.3/Debian-9.4) with ESMTP id v2KAaofn015320 for ; Mon, 20 Mar 2017 23:36:51 +1300 In-Reply-To: X-Bayes-Prob: 0.0001 (Score 0: No Bayes scoring rules defined, tokens from: outbound) X-CanIt-Geo: ip=150.107.175.236; country=NZ; region=Bay of Plenty; city=Tauranga; latitude=-37.6861; longitude=176.1667; http://maps.google.com/maps?q=-37.6861,176.1667&z=6 X-CanItPRO-Stream: base:outbound X-Canit-Stats-ID: 01SWaAPVI - 4de37657f4e2 - 20170320 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 219.88.242.62 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:213171 Archived-At: Tangentially, that performance hit on the interpreted recursive code with lexical-binding enabled is pretty severe! From well under 2 seconds (with dynamic binding) to well over 4 seconds (with lexical binding) in all my results. Is this a known/accepted trade-off for the better byte-compiled performance? I'm assuming it's to do with overheads of lexical closures. The output npostavs generates indicates that it's largely (if not solely) on account of a vast quantity of garbage collection. Perhaps that is all the lexical environments being cleaned up? (Although I would have thought that was a requirement for the byte-compiled code as well, so I'm very much guessing.) Can that be improved, or is this most likely to remain this way? On 20/03/17 11:49, Phil Sainty wrote: > Using npostavs's code: > > | DYNAMIC | interpreted | compiled > -------------------------------------------------------------------- > 25.2 | recursive | 1.55s | 0.94s > | iterative | 1.70s | 1.06s > -------------------------------------------------------------------- > 25.1 | recursive | 1.53s | 0.95s > | iterative | 1.87s | 1.06s > -------------------------------------------------------------------- > 24.5 | recursive | 1.65s | 1.24s > | iterative | 1.43s | 0.95s > -------------------------------------------------------------------- > 24.4 | recursive | 1.78s | 1.25s > | iterative | 1.59s | 1.02s > -------------------------------------------------------------------- > > > | LEXICAL | interpreted | compiled > -------------------------------------------------------------------- > 25.2 | recursive | 4.27s (2.22s in 506 GCs) | 0.64s (0.03s in 6 GCs) > | iterative | 1.56s (0.10s in 23 GCs) | 0.49s (0.03s in 6 GCs) > -------------------------------------------------------------------- > 25.1 | recursive | 4.26s (2.21s in 506 GCs) | 0.64s (0.03s in 6 GCs) > | iterative | 1.58s (0.10s in 23 GCs) | 0.50s (0.03s in 6 GCs) > -------------------------------------------------------------------- > 24.5 | recursive | 4.11s (2.14s in 507 GCs) | 0.92s (0.03s in 6 GCs) > | iterative | 1.57s (0.09s in 22 GCs) | 0.84s (0.03s in 7 GCs) > -------------------------------------------------------------------- > 24.4 | recursive | 4.20s (2.08s in 506 GCs) | 0.91s (0.03s in 6 GCs) > | iterative | 1.65s (0.10s in 23 GCs) | 0.82s (0.03s in 6 GCs) > --------------------------------------------------------------------