探索使用Java进行Emacs Lisp的推测式即时编译
Exploring Speculative JIT Compilation for Emacs Lisp with Java

原始链接: https://kyo.iroiro.party/en/posts/juicemacs-exploring-jit-for-elisp/

最近的基准测试比较了 Juicemacs、Emacs nativecomp 和标准 Emacs Lisp 的性能,结果显示各有权衡。Juicemacs 在简单的列表递增操作中表现挣扎,因为 Java 的整数“装箱”会带来开销,而 nativecomp 由于优化的标签值而在此方面表现出色。然而,nativecomp 在更优化的路径下仍有进一步提升速度的潜力,这一点在其类似任务中的性能表现中得到了证明。 基准测试还测试了函数“建议”(wrappers,用于修改函数行为)。Juicemacs 通过对斐波那契函数进行缓存建议获得了好处,但 nativecomp 目前*无法*编译这些建议“胶水”函数,导致性能下降。类似地,用于交互式命令的交互式表单似乎也绕过了 nativecompilation。 需要进一步的基准测试来确定这些限制对用户体验的实际影响,但这些结果突出了 nativecomp 可以改进的领域。

黑客新闻 新 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 探索使用Java进行Emacs Lisp的推测性即时编译 (iroiro.party) 4点 由 gudzpoz 1小时前 | 隐藏 | 过去 | 收藏 | 讨论 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请YC | 联系 搜索:
相关文章

原文

Let’s look at some more benchmarks.

bench-advice-inclist.svg
Figure 8: Results of two more benchmarks

For example, for the inclist/inclist-type-hints benchmarks (the green columns above, namely, increment-elements-in-list), Juicemacs is really slow. This comes partly from the cost of Java “boxing” integers – it has to allocate for every incremented integer, while Emacs nativecomp, with tagged values, does not.

On the other hand, for this particular benchmark, Emacs nativecomp actually has fast paths for all of the operations . That’s why it can be so fast, and that also proves that, compared to the Fibonacci benchmarks, nativecomp has a lot of potential for improvement if it gets more fast paths.

  nativecomp Juicemacs
advice Glue not native-compiled JIT-capable
inclist All operations on fast path Java integer boxing costs

There is another benchmark here that uses advices—Emacs Lisp supports using advices to override functions by wrapping the original function and an advice function inside a glue function:

;; The "glue" functions defined in nadvice.el, where
;; "car" is the advice and "cdr" is the original.
(defvar advice--how-alist
  (advice--make-how-alist
   (:around (apply car cdr r))
   (:before (apply car r) (apply cdr r))
   (:after (prog1 (apply cdr r) (apply car r)))
   (:override (apply car r))
   (:after-until (or (apply cdr r) (apply car r)))
   (:after-while (and (apply cdr r) (apply car r)))
   (:before-until (or (apply car r) (apply cdr r)))
   (:before-while (and (apply car r) (apply cdr r)))
   (:filter-args (apply cdr (funcall car r)))
   (:filter-return (funcall car (apply cdr r)))))

In this benchmark, we advise the Fibonacci function to cache the first ten entries to speed up computation, as can be seen in the speed-up in the Juicemacs results. However, it seems that nativecomp does not yet compile glue functions (as of GNU Emacs 30), which makes advices slower.

(define-advice elb-fibn-rec-adviced (:before-until (n) elb-fibn-lookup-table-advice)
  (and
   (< n 10)
   (aref [0 1 1 2 3 5 8 13 21 34] n)))

Every (interactive ...) function in Emacs comes with an interactive form, which injects interaction info into function arguments when run interactively:

(interactive-form 'evil-goto-first-line)
(interactive (byte-code "\10\205\7\0\301\10!C\207" [current-prefix-arg prefix-numeric-value] 2))

However, similar to advices, it seems to me that these interactive forms are also not native-compiled. Of course, we can’t know whether or not this affects user experience without more benchmarking.

联系我们 contact @ memedata.com