unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrea Corallo <akrl@sdf.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: On elisp running native
Date: Thu, 28 Nov 2019 22:52:47 +0000	[thread overview]
Message-ID: <xjfo8wv7gw0.fsf@sdf.org> (raw)
In-Reply-To: <jwvmucfzpzc.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 28 Nov 2019 16:06:04 -0500")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> [ I wasn't able to follow all the explanations at
>>>   http://akrl.sdf.org/gccemacs.html, such as the one around "function
>>>   frames", with which I'm not familiar.  Are these like activation
>>>   frames? ]
>> Yes I think we both mean the same.  In this case basically where we store
>> automatic variables and data related to the single activated function.
>
> OK, thanks.  I think "activation frame" is the standard term (of which
> there can be several on the stack at the same time in case of recursion).

OK good to know, I don't have an official education as a compiler engineer
so my nomenclature can be occasionally a bit off.

>>> - How did you get there?  I see some "we" in the web page, which makes
>>>   it sound like you weren't completely alone.
>> Sorry for that I'm not much into using 'I'.
>
> That's OK, but I see you tried to use it as a clever ploy to dodge the
> initial question: how did you get there?

Sorry I though the question was more to understand if there were other
contributors for copyright reasons.

On my side the long story short is about this:

I was already into gcc and libgccjit.  I thought was cool to apply these
to some lisp implementation.  I decided to have Emacs as a target cause
I imagined would have been useful and because I'm obviously an Emacs
user and fan.

I wanted to do something with the potential to be completed and
up streamed one day.  Therefore I discarded the idea of writing the full
lisp front-end from scratch.  On the other side I considered the idea
seen in previous projects of reusing the byte-compiler infrastructure
quite clever.

The original plan was the to do something like Tromey's jitter but gcc
based and with a mechanism to reload the compiled code.  So I did it.

I had a single pass compiler all written in C that was decoding the byte
code and driving libgccjit.

I was quite unhappy with that solution for two reasons:

1- The C file was getting huge without doing anything really smart.

2- After some test and observation became clear that to generate
efficient code this approach was quite limited and a more sophisticated
approach with a propagation engine and the classical compiler theory
data structures was needed.  The idea of just driving gcc and having
everything magically optimized was simply naive.

So I came up with the idea of defining LIMPLE and using it as interface
between the C and the lisp side of the compiler.

In this way I had the right IR for implementing the 'clever' algorithmic
into lisp and the C side has just to 'replay' the result on libgccjit.
Moreover it saved me from the pain of exposing libgccjit to lisp.

I then realized I could, instead of decoding op-codes, just spill the LAP
from the byte-compiler.  This makes the system simpler and more robust
cause I get also information on the stack depth I can double check or
use during limplification.

Lastly I managed to reuse the information defined in the byte-compiler
on the stack offset of every op to generate automatically or semi the
code of my compiler for the translation from LAP to LIMPLE for good part
of the op codes.

The rest just iterating over tests debugging and implementing.

I'm not sure this answer the question. Does it?

>>> - Have you tried to use the compiler as benchmark (i.e. how much faster
>>>   can Emacs compile (either byte-compile or native-compile)) if the
>>>   compiler code is native-compiled (since it's all using
>>>   lexical-binding already)?
>> I use the compiler native compiled but because of the previous point I
>> think is hard to measure the difference.
>
> How 'bout measuring the time to byte-compile a given set of files, then:
> first using the byte-compiled compiler and then using the
> native-compiled compiler (where "compiler" here means at least cconv.el,
> byte-opt.el, bytecomp.el, and macroexp.el)?

I think is a test we can do, sounds like a very good benchmark.

> BTW, I think developing a good set of Elisp benchmarks is useful
> independently from this, so I'd encourage you to submit your benchmarks
> as a new GNU ELPA package (we could also incorporate it into Emacs
> itself, but I think we'll want to use it to compare performance between
> diverse Emacsen, so a separate package makes more sense).

OK I'll do some clean-up then.  BTW I think for dhrystone my colleague
has to do the paper-works and we have to look also into the original
license.

> Maybe someone from the Gnus side will want to submit more benchmarks
> (such as one that manipulates "sets/ranges or article numbers").
>
>> Talking about compile time in general I think we are looking at
>> something like few minutes to compile the whole Emacs at speed 0.  The
>> time goes up to say ~4 hours with 4 cores for the same job at speed 2.
>
> [ Compile time varies for me with the normal Emacs from less than
>   5 minutes to more than an hour depending on the machine on which
>   I compile, so absolute times don't speak to me very much.  ]
>
> So, IIUC, with enough optimisations enabled, we gets into "a long
> time" territory?

Yes feels like compiling C++ :x

>> I think it will be interesting to look into the gcc compilation pipe to
>> see where we are losing so much time, my guess is that there's one or
>> few passes that go a little nuts with all the moves we do.  I had no
>> time to look into it but my guess is that once understood the problem we
>> can probably dime it down.
>
> Indeed, I'm surprised that compilation time in gcc would blow up by
> significantly more than a factor 10 just because of optimisation
> options, so either we're using optimisations which are really too
> costly, or there should be something we can do to avoid this blow up
> without any significant performance loss.

Me too.  My guess is that because the code we feed into gcc does not
look at all like it's written by a human something has just to be tuned
somewhere in some pass.  I'm looking forward to investigate it but I'm a
bit saturated now.

I'm quite confident we can at least mitigate it but in general maybe we
should give also the possibility to specify different optimization
levels per function granularity.

Andrea

--
akrl@sdf.org



  reply	other threads:[~2019-11-28 22:52 UTC|newest]

Thread overview: 210+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-28  6:54 On elisp running native Andrea Corallo
2019-11-28 11:31 ` Óscar Fuentes
2019-11-28 14:07   ` Andrea Corallo
2019-11-28 12:47 ` Lars Ingebrigtsen
2019-11-28 20:15   ` Andrea Corallo
2019-11-29  6:03     ` Lars Brinkhoff
2019-11-28 16:04 ` Stefan Monnier
2019-11-28 17:28   ` Andrea Corallo
2019-11-28 21:06     ` Stefan Monnier
2019-11-28 22:52       ` Andrea Corallo [this message]
2019-11-29  0:20       ` Eric Abrahamsen
2019-11-29 14:59       ` Andrea Corallo
2019-11-29 15:10         ` Eli Zaretskii
2019-11-29 15:30           ` Stefan Monnier
2019-12-01 10:34             ` Andrea Corallo
2019-12-01 15:27               ` Stefan Monnier
2019-11-29 16:43           ` Andrea Corallo
2019-11-29 19:26             ` Eli Zaretskii
2019-11-29 21:18               ` Andrea Corallo
2019-12-08 20:18 ` Andrea Corallo
2019-12-26 13:05   ` Andrea Corallo
2019-12-26 17:30     ` Eli Zaretskii
2019-12-26 18:14       ` Andrea Corallo
2019-12-26 20:37         ` Eli Zaretskii
2019-12-26 22:10           ` Andrea Corallo
2019-12-27  9:12             ` Eli Zaretskii
2019-12-27 10:46               ` Andrea Corallo
2019-12-27 14:03                 ` Eli Zaretskii
2019-12-28  1:17               ` Richard Stallman
2019-12-28  7:50                 ` Eli Zaretskii
2019-12-28  8:17                 ` Andrea Corallo
2019-12-29  0:08                   ` Richard Stallman
2019-12-29  9:29                     ` Andrea Corallo
2019-12-28 13:07               ` Dmitry Gutov
2019-12-28 13:28                 ` Eli Zaretskii
2019-12-28 19:56                 ` Óscar Fuentes
2019-12-29 19:59                 ` chad
2019-12-30  8:17                   ` arthur miller
2019-12-30 14:09                     ` Dmitry Gutov
2019-12-30 15:25                     ` Eli Zaretskii
2019-12-30 22:03                       ` arthur miller
2019-12-31  3:34                         ` Eli Zaretskii
2019-12-30 13:56                   ` Dmitry Gutov
2019-12-30 14:04                     ` Juanma Barranquero
2019-12-30  8:47                 ` Achim Gratz
2019-12-27 15:53             ` Stefan Monnier
2019-12-27 21:02               ` Andrea Corallo
2019-12-27 22:19                 ` Stefan Monnier
2019-12-28  8:34                 ` Eli Zaretskii
2019-12-28  8:56                   ` Andrea Corallo
2019-12-28 10:06                     ` Eli Zaretskii
2019-12-28 11:57                       ` Andrea Corallo
2019-12-28 13:34                         ` Eli Zaretskii
2019-12-28 14:35                           ` Andrea Corallo
2019-12-28 18:38                             ` Eli Zaretskii
2019-12-28 22:13                               ` Andrea Corallo
2019-12-31  9:55                               ` Andrea Corallo
2019-12-31 15:49                                 ` Eli Zaretskii
2020-02-24 23:21                       ` Andrea Corallo
2020-02-25  6:14                         ` yyoncho
2020-02-25  7:29                           ` Eli Zaretskii
2020-02-25 12:59                             ` Andrea Corallo
2020-02-28  4:34                               ` Eli Zaretskii
2020-02-28  8:26                                 ` Andrea Corallo
2020-02-28  9:23                                   ` yyoncho
2020-04-26 12:00                           ` Andrea Corallo
2020-04-27  4:41                             ` yyoncho
2019-12-26 20:26     ` Stefan Monnier
2019-12-26 20:58       ` dick.r.chiang
2019-12-26 21:57       ` Andrea Corallo
2019-12-27  8:22         ` Eli Zaretskii
2019-12-27 10:49           ` Andrea Corallo
2019-12-28 16:10           ` dick.r.chiang
2019-12-28 17:31             ` Eli Zaretskii
2019-12-31 10:24           ` Andrea Corallo
2019-12-31 15:51             ` Eli Zaretskii
2019-12-31 16:21               ` Andrea Corallo
2019-12-31 16:47                 ` Eli Zaretskii
2019-12-31 22:15                   ` Óscar Fuentes
2020-01-01 12:41                   ` Andrea Corallo
2020-01-01 15:14                     ` Stefan Monnier
2020-01-01 18:42                       ` Andrea Corallo
2020-01-02  7:55                         ` arthur miller
2020-01-02 11:31                           ` Andrea Corallo
2020-01-02 13:53                             ` Eli Zaretskii
2020-01-04 18:17                           ` Stefan Monnier
2020-01-05  1:33                             ` Jean-Christophe Helary
2020-01-05  4:51                               ` Stefan Monnier
2020-01-05  5:18                                 ` Jean-Christophe Helary
2020-01-05  6:36                                   ` Stefan Monnier
2020-01-02 13:47                         ` Eli Zaretskii
2020-01-04 18:14                         ` Stefan Monnier
2020-01-05 10:00                           ` Andrea Corallo
2020-01-02 11:47                       ` Andrea Corallo
2020-01-02 16:52                         ` Ergus
2020-01-02 17:55                           ` Andrea Corallo
2020-01-11 14:10                         ` Andrea Corallo
2020-02-04 11:28                           ` Andrea Corallo
2020-02-04 15:30                             ` Eli Zaretskii
2020-02-04 18:39                               ` Andrea Corallo
2020-02-04 18:58                                 ` Eli Zaretskii
2020-02-04 19:00                                 ` Paul Eggert
2020-02-04 20:30                                   ` Andrea Corallo
2020-02-05 10:15                                     ` Andrea Corallo
2020-02-05 14:24                                       ` Stefan Monnier
2020-02-15  9:29                                         ` Andrea Corallo
2020-02-16 18:18                                           ` Andrea Corallo
2020-02-22 10:15                                             ` On elisp running native - deferred compilation Andrea Corallo
2020-02-22 14:19                                               ` Stefan Monnier
2020-03-04 19:34                                             ` On elisp running native Andrea Corallo
2020-03-04 20:21                                               ` Michael Albinus
2020-03-04 22:16                                                 ` Andrea Corallo
2020-03-05 19:33                                                   ` Michael Albinus
2020-03-06 21:44                                                     ` Andrea Corallo
2020-03-07  9:09                                                       ` Michael Albinus
2020-03-07  9:33                                                         ` Andrea Corallo
2020-03-07  9:41                                                           ` Michael Albinus
     [not found]                                                             ` <xjf36akjx8e.fsf@sdf.org>
     [not found]                                                               ` <87y2sca2ex.fsf@gmx.de>
     [not found]                                                                 ` <xjfy2scigxn.fsf@sdf.org>
     [not found]                                                                   ` <xjftv30hytf.fsf@sdf.org>
2020-03-07 17:57                                                                     ` Michael Albinus
2020-03-07 18:49                                                                       ` Andrea Corallo
2020-03-07 18:54                                                                         ` Michael Albinus
2020-03-07 19:19                                                                           ` Andrea Corallo
2020-03-08 15:03                                                                             ` Andrea Corallo
2020-03-08 20:16                                                                               ` Michael Albinus
2020-03-08 20:55                                                                                 ` Andrea Corallo
2020-03-08 21:09                                                                                   ` Michael Albinus
2020-03-08 21:29                                                                                     ` Andrea Corallo
2020-03-08 21:32                                                                                       ` Michael Albinus
2020-03-08 21:37                                                                                         ` Andrea Corallo
2020-03-05 10:54                                               ` Adam Porter
2020-03-05 12:43                                                 ` Gong-Yi Liao 廖宮毅
2020-03-05 13:27                                                   ` Andrea Corallo
2020-03-08 14:37                                                     ` Gong-Yi Liao 廖宮毅
2020-03-08 15:13                                                       ` Andrea Corallo
2020-03-15 19:00                                                     ` Gong-Yi Liao 廖宮毅
2020-03-15 20:00                                                       ` Andrea Corallo
2020-03-05 13:19                                                 ` Andrea Corallo
2020-03-05 14:42                                                   ` Adam Porter
2020-03-05 19:46                                                     ` Andrea Corallo
2020-03-06 21:15                                                   ` Adam Porter
2020-03-06 21:23                                                     ` Adam Porter
2020-03-06 21:52                                                       ` Andrea Corallo
2020-03-11 22:04                                                 ` Andrea Corallo
2020-03-12 17:10                                                   ` Adam Porter
2020-03-12 17:34                                                   ` Stefan Monnier
2020-03-12 18:03                                                     ` Andrea Corallo
2020-03-23 21:36                                               ` On elisp running native - Update7 Andrea Corallo
2020-03-24  2:59                                                 ` Gong-Yi Liao 廖宮毅
2020-03-24  8:44                                                   ` Andrea Corallo
2020-05-16 15:24                                                 ` On elisp running native - Update 8 Andrea Corallo
2020-05-16 16:21                                                   ` Eli Zaretskii
2020-05-16 20:44                                                     ` Andrea Corallo
2020-05-16 18:22                                                   ` Gregor Zattler
2020-05-16 19:59                                                     ` Andrea Corallo
2020-05-17  5:26                                                       ` Gregor Zattler
2020-06-14 13:23                                                   ` On elisp running native - Update 9 Andrea Corallo
2020-06-14 17:23                                                     ` arthur miller
2020-06-15  5:04                                                     ` Gong-Yi Liao 廖宮毅
2020-06-15  7:41                                                       ` Andrea Corallo
2020-06-17 23:54                                                     ` Stefan Monnier
2020-06-18  6:55                                                       ` Andrea Corallo
2020-07-16 20:00                                                     ` On elisp running native - Update 10 Andrea Corallo via Emacs development discussions.
2020-08-17 18:43                                                       ` On elisp running native - Update 11 Andrea Corallo via Emacs development discussions.
2020-08-18  5:13                                                         ` Arthur Miller
2020-08-18  8:17                                                           ` Andrea Corallo via Emacs development discussions.
2020-09-26 10:35                                                         ` On elisp running native - Update 12 Andrea Corallo via Emacs development discussions.
2020-09-26 14:29                                                           ` T.V Raman
2020-09-26 14:56                                                             ` Andrea Corallo via Emacs development discussions.
2020-09-26 15:07                                                               ` T.V Raman
2020-09-28 12:22                                                                 ` Lars Brinkhoff
2020-09-28 14:03                                                                   ` T.V Raman
2020-09-27 10:35                                                           ` Arthur Miller
2020-09-27 18:28                                                             ` Andrea Corallo via Emacs development discussions.
2020-09-27 18:30                                                               ` Lars Ingebrigtsen
2020-09-27 20:39                                                                 ` T.V Raman
2020-09-27 22:10                                                                 ` Stefan Monnier
2020-09-28  6:06                                                                 ` Eli Zaretskii
2020-09-28 10:28                                                                   ` Andrea Corallo via Emacs development discussions.
2020-09-28 10:45                                                                     ` Eli Zaretskii
2020-09-28 11:02                                                                       ` Andrea Corallo via Emacs development discussions.
2020-09-27 20:37                                                               ` T.V Raman
2020-09-28 14:10                                                           ` Yuan Fu
2020-09-28 14:51                                                             ` Andrea Corallo via Emacs development discussions.
2020-09-28 15:20                                                               ` Yuan Fu
2020-09-28 15:32                                                                 ` Andrea Corallo via Emacs development discussions.
2020-09-28 15:19                                                           ` Caio Henrique
2020-09-28 15:39                                                             ` Andrea Corallo via Emacs development discussions.
2020-09-28 16:12                                                               ` Caio Henrique
2020-09-28 17:21                                                                 ` Andrea Corallo via Emacs development discussions.
2021-01-01 18:37                                                           ` On elisp running native - Update 13 Andrea Corallo via Emacs development discussions.
2021-01-01 20:07                                                             ` tomas
2020-01-01 15:19                     ` On elisp running native Óscar Fuentes
2020-01-01 18:48                       ` Andrea Corallo
2020-01-01 14:59             ` Stefan Monnier
2020-03-15 14:21 ` Spenser Truex
2020-03-15 20:10   ` Andrea Corallo
2020-03-18 14:58     ` Lars Brinkhoff
2020-03-18 17:14       ` Andrea Corallo
  -- strict thread matches above, loose matches on Subject: below --
2020-01-02 21:47 arthur miller
2020-03-06 13:28 Zhu Zihao
2020-03-06 17:51 ` Andrea Corallo
2020-03-09 17:55   ` Zhu Zihao
2020-03-09 18:52     ` Andrea Corallo
2020-03-09 19:14       ` Zhu Zihao
2020-03-09 19:41         ` Andrea Corallo
2020-03-09 21:06         ` Stefan Monnier
2020-03-09 19:18       ` Eli Zaretskii
2020-03-09 19:42         ` Andrea Corallo
2020-04-05 21:48         ` Andrea Corallo
2020-03-10 16:15   ` Zhu Zihao
2020-03-10 17:46     ` Andrea Corallo

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=xjfo8wv7gw0.fsf@sdf.org \
    --to=akrl@sdf.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).