unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: Why is lexical binding so slow?
Date: Sun, 02 Jul 2017 14:36:05 -0400	[thread overview]
Message-ID: <jwvk23q3d8k.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: CAArVCkScvmjtrBovGRZWthp8JjxOD1_C+NSSY-E5jNPKJxhTJw@mail.gmail.com

> https://github.com/mooz/js2-mode/issues/426#issuecomment-312506855.
> Why is that?

Depends on specifics, so someone would have to investigate.  I remember
discussing a performance problem in js2 with Dmitry a while ago (it
lead to the introduction of new byte-codes controlled by
byte-compile--use-old-handlers).  A minor modification to the source
code eliminated the performance difference between lexbind and dynbind,
and the new handlers bytecodes made the lexbind case slightly
faster (or maybe both cases?), IIRC.

> Shouldn't code compiled with lexical binding be at least as
> fast as code compiled with dynamic binding?

Not necessarily, no.  E.g. when you use `mapcar` and the function
argument has free lexical variables, the lexbind code will have to build
a closure to pass to mapcar.  The access to the lexical vars in the
closure will usually be faster than the corresponding access to those
vars via dynbinding, so if mapcar makes enough calls lexbind can still
be faster, but if mapcar makes few calls, dynbind is faster.


        Stefan




  reply	other threads:[~2017-07-02 18:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-02 18:15 Why is lexical binding so slow? Philipp Stephani
2017-07-02 18:36 ` Stefan Monnier [this message]
2017-12-25 21:20   ` Philipp Stephani
2017-12-26  4:49     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvk23q3d8k.fsf-monnier+gmane.emacs.devel@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).