From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Nickolas Lloyd Newsgroups: gmane.emacs.devel Subject: Re: Emacs Lisp JIT Compiler Date: Sun, 11 Dec 2016 12:37:19 -0500 Message-ID: <87eg1e2wq8.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1481477976 24637 195.159.176.226 (11 Dec 2016 17:39:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 11 Dec 2016 17:39:36 +0000 (UTC) To: burton.samograd@autodesk.com, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 11 18:39:29 2016 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 1cG85v-0004tx-VP for ged-emacs-devel@m.gmane.org; Sun, 11 Dec 2016 18:39:28 +0100 Original-Received: from localhost ([::1]:56506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cG85z-00044T-U1 for ged-emacs-devel@m.gmane.org; Sun, 11 Dec 2016 12:39:31 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cG85I-00044D-Hs for emacs-devel@gnu.org; Sun, 11 Dec 2016 12:38:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cG85E-0004fP-QO for emacs-devel@gnu.org; Sun, 11 Dec 2016 12:38:47 -0500 Original-Received: from mail-yw0-f178.google.com ([209.85.161.178]:33596) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cG85E-0004dj-ME for emacs-devel@gnu.org; Sun, 11 Dec 2016 12:38:44 -0500 Original-Received: by mail-yw0-f178.google.com with SMTP id r204so49413795ywb.0 for ; Sun, 11 Dec 2016 09:38:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:in-reply-to:date:message-id:mime-version :content-transfer-encoding; bh=V5Huw64Q1aAA3c6Innt41ES2yv5MIZzxWPY4MyUAS6g=; b=k4okwaVFYEOGyfjVbjXdSpXRm/BiAbMDX/XNkrL5Lzt3G42rsDQn/AJDztKqYxhbZL ZM6fCjMdNKusNAJjzWdcQlHV5BSHQJ6obZ9mO8nR3ehUaDx5ET+G1h9WFlmILONhZbWR qQshd8ksZuXXpQknh/3J9a97yRt6UoLzo3VjJrJGTmZ71vcDNy3KiH8fZWwjAjsxVuG6 xJHl6vsrhn+xHsEbwca5ydEY53BrKpFwrvjkfINkPv8eqk3IhRnPkDIUnZwtHJyInqYh HzV+phwP83PnekfiEo6Ag34RmKUtcz8htyEjnNqAderEyGz1Q7ILgkGGeb1f3l+3Gx2j BtMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:in-reply-to:date:message-id :mime-version:content-transfer-encoding; bh=V5Huw64Q1aAA3c6Innt41ES2yv5MIZzxWPY4MyUAS6g=; b=hQcZJmGWimgOT4wpbmg0dZy/4y2hBokMrPjiHR/ODcO4fNs2LQTei0MuziRbmp8YDN 9x0o2Z58txu6JUDvJb9rKiliFlvfB7cxDtbvFUSvUiOKCc6ApK5d/RzzgkvIVsvumJH1 372nmaQuMNtBDi5ZBK0fWD+kQiAOo1EArE+ZYAZ1Xtc+N9ofrRlswlKEECH3PUh+mRuK FRIi5I0/Ch9BmX06lswe1WRSPpaFVa++2QK+Nera+FrHwYRkDfn6G9mxGksKaMPgC9sc wUCLJEV5K8sRP2SO63YzXrntU4Q4ITDgfwtKZuF7KrmyENHnyag3Qk8/Ymw6c90Q8YcG jt1Q== X-Gm-Message-State: AKaTC02Yyubp8GdsBalv+AWjgwTQxr4PkL9BJtr0/X3JOgs3waENxcwrtGOIoGUD5WiISA== X-Received: by 10.13.222.133 with SMTP id h127mr81300289ywe.329.1481477840481; Sun, 11 Dec 2016 09:37:20 -0800 (PST) Original-Received: from localhost (cpe-71-71-101-222.triad.res.rr.com. [71.71.101.222]) by smtp.gmail.com with ESMTPSA id k129sm16766322ywb.43.2016.12.11.09.37.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Dec 2016 09:37:20 -0800 (PST) In-Reply-To: 460FFFB2-04B6-4037-8282-5FCCBC2F4168 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.161.178 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:210288 Archived-At: Burton Samograd wrote: > By showing this ida/work I=E2=80=99m hoping not to get it included in ema= cs > proper, but to show a relatively simple way to speed things up. I=E2=80= =99m > sure there are better/alternate implementations that would both be > cleaner and give better speedups, but this was as far as this POC went > so far. Coincidentally, for the past few weeks I've been working on a very similar idea, with a slightly different implementation. Instead of every instruction compiling down to a function call that directly mimics the interpreter, in many places those intermediate functions are removed and replaced by direct calls to e.g. Ffuncall, Fconcat, etc. Instead of adding a new instruction to replace the original bytecode, a pointer to the function is stashed away inside of the bytecode vector. Other than that it looks to be largely similar. The code is in a repo at: https://github.com/smindinvern/emacs.git =20=20=20=20 in branch `elc-jit'. It's based off of emacs-25, and so far during my testing enabling the JIT globally seems to be stable. There seem to be some performance penalties with that, though, due to some functions which are byte-compiled many times at runtime.... I was able to produce gains of 15-20% on your ray-tracing benchmark, though, so there is a significant speedup for individual functions. I bring this up, for those interested, because it is fully working with a recent version of emacs. Maybe there are some things that could be learned from each implementation? I've also looked into using libgccjit, though the object model seems a bit more complicated, with distinctions made between lvalues, rvalues, etc. I'll probably do some work on porting my code to libgccjit at some point to see how the performance compares. Thanks, Nick