From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Hi-Angel Newsgroups: gmane.emacs.help Subject: Lexical binding doesn't seem to be faster? Date: Thu, 7 Mar 2019 02:36:39 +0300 Message-ID: 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="3278"; mail-complaints-to="usenet@blaine.gmane.org" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 07 00:37:08 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h1g60-0000iD-0Q for geh-help-gnu-emacs@m.gmane.org; Thu, 07 Mar 2019 00:37:08 +0100 Original-Received: from localhost ([127.0.0.1]:41203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1g5y-00071v-Lz for geh-help-gnu-emacs@m.gmane.org; Wed, 06 Mar 2019 18:37:06 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44543) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1g5o-00071q-IA for help-gnu-emacs@gnu.org; Wed, 06 Mar 2019 18:36:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1g5m-0001Oj-MS for help-gnu-emacs@gnu.org; Wed, 06 Mar 2019 18:36:56 -0500 Original-Received: from mail-it1-x12c.google.com ([2607:f8b0:4864:20::12c]:52875) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1g5k-0001NT-Mk for help-gnu-emacs@gnu.org; Wed, 06 Mar 2019 18:36:52 -0500 Original-Received: by mail-it1-x12c.google.com with SMTP id g17so12435909ita.2 for ; Wed, 06 Mar 2019 15:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=yjxaTuT8C8fNoi+6nUoDLlltfPjtZ76e7vzsye/xmbE=; b=uJPaS5ftc7bZ9xCtPTw76Yj6n5ffe0sG9mRyl7AJpaT1lCpIv+bXt3ozLjvkqyjail wPB/o0g6yf8obAX+ToawGk2WyvmMv/V2nxiKEKMfpcce+JGm9kBGhIpfyAyukEzwW9oJ H6peGzz+Qdfv1msotYE4nk4lCiuKwjqn4symP0VqbYKv8fl+efTMk5yZs++Pquq74fjx rXPngcndUSVm2JdDU1v8OWiXCa8ttz2JkbarxzIXV1Hm7wxjjq7HKNO2RnJVhNqcGimH IpszsnEacKea+02B41OyHXUHZ5SDOgn6ID7lzy7Nr4w3MkaBtSrLdvRHQbx5FyAlK+ep zEqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=yjxaTuT8C8fNoi+6nUoDLlltfPjtZ76e7vzsye/xmbE=; b=pGonGqS/gr1Vs2guOkmqiy0NhkSgKAbA1U9HY7GnmJ4Nkk1hfBMlAKnMONFcLzd5zt eOWv7R+0omjtkDG5E6YY7ksxKhaeA1nxZpnXvC4bBk1UyeYk1zDc3aeF/KiOD2QQy5bT YmeGwQUh7BCDPToJzQAamcNOOufy+t4ktgtEKJuk7BiOmoN4kXRcSqnbM3ftw/3+KqPc FXobApSgz15PT64YsD4//+YZ4byG10mrbkc6SHDxhaSfXCT8d3wbZzgcMzBUWVTkVTAu EZyJIjmS88+P6/Hw4oqA+vsMyPxF9hLDQnVj8kSQpgDDxTG098RWOvgddRYfrduwjD+4 OV7w== X-Gm-Message-State: APjAAAU8Ikj9ioBKW0AdXT+LakgrJNnHAyFM/uv8UCPWVbygWV0tsjd3 sGd2nrmK3vy3dMZg7R7eSmzHyf1DsFbqiZR9okTrQ+NU X-Google-Smtp-Source: APXvYqwBcCIawZ6LvF4gGr4vLy5wNx36OSCO9JJuo1qbQimoxEbcOIcie8CUx/uSkl+0zqTpYk1IXAhfZ+CedkR/VfE= X-Received: by 2002:a24:7546:: with SMTP id y67mr3595079itc.16.1551915410165; Wed, 06 Mar 2019 15:36:50 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::12c X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:119566 Archived-At: I've stumbled upon a discussion about converting Emacs code to a faster lexical-binding and that help needed. I noted that cc-mode.el I'm regularly use doesn't have one, and figured I could help. So I inserted to cc-mode.el in emacs-git revision I have: ;;; -*- lexical-binding: t -*- The first bad sign happened to be sizes of cc-mode.elc: ;;; -*- lexical-binding: t -*- | 217581 ;;; -*- lexical-binding: nil -*- | 212542 Lexical-binding bloats byte-code by 5KB. Odd. I tried comparing assembly, but without experience in reading lisp assembly I haven't come up with anything. So I thought "Okay, must be heavy inlining; let's just compare the speed". So, I took someone's function `with-timer` for benchmarking=C2=B9; and then for both t and nil lexical-binding I did following steps: 1. `byte-compile` `cc-mode.el` 2. `load-file` `cc-mode.elc` 3. open a 5k lines C file=C2=B2 4. Execute multiple times `(with-timer (c-font-lock-fontify-region 0 (point-max)))` 5. Kill the buffer. These are results I got: ;;; -*- lexical-binding: t -*- | 1.174s, 1.144s, 1.177s, 1.125s, 1.17= 7s ;;; -*- lexical-binding: nil -*- | 1.037s, 1.061s, 1.037s, 1.037s, 0.99= 1s 1: https://emacs.stackexchange.com/a/541/2671#how-do-i-measure-performance-= of-elisp-code 2: https://gitlab.freedesktop.org/libinput/libinput/blob/9a2d6f55b1276da11d= d9b2c4c8e22a405576dfea/src/libinput.h