From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: [PATCH]: Add new bytecode op `switch' for implementing branch tables. Date: Thu, 9 Feb 2017 12:32:45 -0500 Message-ID: <363b8622-feb0-ae73-eb68-77037a2dd77c@gmail.com> References: <1b07c68a-873e-83c8-246d-423bc83a3881@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1486663143 4329 195.159.176.226 (9 Feb 2017 17:59:03 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 9 Feb 2017 17:59:03 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 Cc: Stefan Monnier , "emacs-devel@gnu.org" To: Vibhav Pant Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 09 18:58:59 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 1cbszh-0000r0-Up for ged-emacs-devel@m.gmane.org; Thu, 09 Feb 2017 18:58:58 +0100 Original-Received: from localhost ([::1]:39498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbszn-0000RO-H7 for ged-emacs-devel@m.gmane.org; Thu, 09 Feb 2017 12:59:03 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbsaS-0003cg-Kw for emacs-devel@gnu.org; Thu, 09 Feb 2017 12:32:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbsaO-000403-U1 for emacs-devel@gnu.org; Thu, 09 Feb 2017 12:32:52 -0500 Original-Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:33866) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cbsaO-0003zV-QF for emacs-devel@gnu.org; Thu, 09 Feb 2017 12:32:48 -0500 Original-Received: by mail-qk0-x243.google.com with SMTP id e1so1593631qkh.1 for ; Thu, 09 Feb 2017 09:32:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=W6aKSN6oAVCFu0B+XJTXzgxF1f9wym1rsLwbVkBakmY=; b=qATTOUHLHtkj5cD8C11pkT+zV0MpnZayK07po61dFSi/QHc/x12sZ9bFU+r4P7Q/t1 xNo0L9R9wfq7+xJ/35PlpEOxI5KV8l5p6Sk+9BwlPOAs1t+sA+VD3GaqqvgYpP8yS8ir TThAKwT8/0Chy4/2att9Rna1F272ZL35FYnWKbUTDW2bMxXK2Qfgo6hs1116VPI7fpUt k3T4oAg/tDowdiBfoSReU9hmC8PVRLcMHdX7C5DWzQVOflsdI0cvKWBOhO0rA4AfCOqf 3oXJV7zeK6JIGCHcMEVkql5YiAgTJBWZG/oXMGL4WEbmw5IG3C6G1a8FpeVvW+3slHcJ xF2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=W6aKSN6oAVCFu0B+XJTXzgxF1f9wym1rsLwbVkBakmY=; b=cCFPnnigU2gzXW5fyowbjNNi/TCLMSWnu39n1Hft5WsWO/Rr8xq3SiG3uBJDQhOv10 VFWk4jkLGTEKC4GYVKG066pLeKDBXib1TflapcSuSrMcIWQhUPFEYcnCZH/2sl10zDCN BAoHjDlGjX/PsG5qonafo04vjYpERZtsdKwC79/3yBLXRik1MAdqygcwVpatCAC80x3Z bXuXcTa3qT2wWMP0Uo2arf44rzUExx0aPWJSBKOUcKHHu5sMAaJkyCbiyG4LQMySNruf A2basG29matqHhY3NzXNS5SytDzFR+mgCAIgeG94I9HTitNquAqRH4aTFCJwcXuLHkk2 HUNw== X-Gm-Message-State: AMke39mYxCnGmOI6P5olpzc3Hh2T3AB9O4ABzMkeSdivS6qj5brZ79wiWvUjHWLlKowERw== X-Received: by 10.55.79.146 with SMTP id d140mr3831405qkb.69.1486661567084; Thu, 09 Feb 2017 09:32:47 -0800 (PST) Original-Received: from [18.111.113.197] (dhcp-18-111-113-197.dyn.mit.edu. [18.111.113.197]) by smtp.gmail.com with ESMTPSA id m30sm9725367qtg.10.2017.02.09.09.32.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 09:32:46 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::243 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:212174 Archived-At: On 2017-02-08 08:38, Vibhav Pant wrote: > On Tue, Feb 7, 2017 at 9:26 PM, Clément Pit-Claudel wrote: >> The timings fluctuate quite a bit, but the byte-switch branch seems >> to be about 5-7% slower. Hopefully linear-scan hash tables will >> make things much faster :) > > The following patch makes hash_lookup use linear search when the > number of keys in the hash table is <= 5 (chosen arbitrarily). switch > bytecode run with this patch takes 15.96 seconds to run the > benchmark, while the goto-if-nil code takes 17.15 seconds. Thanks! Indeed, here are new timings: $ rm -f *.elc; emacs-byte-switch -Q --batch --eval '(byte-compile-file "eval-expr.el")'; time emacs-byte-switch -Q --batch -L . -l benchmark-expr.el real 0m3.703s user 0m3.664s sys 0m0.012s $ rm -f *.elc; emacs -Q --batch --eval '(byte-compile-file "eval-expr.el")'; time emacs -Q --batch -L . -l benchmark-expr.el real 0m3.878s user 0m3.860s sys 0m0.016s Things still fluctuate, but the byte-switch branch is now consistently faster, by roughly 5% :) Clément.