[新闻] emacs master 合并了 feature/noverlay 分支

这个新合并的特性目的是提高 overlay 的性能。将会包含在明年春季发布的 Emacs 29.1 中

https://lists.gnu.org/archive/html/emacs-devel/2022-10/msg02166.html

7 个赞

据介绍 noverlay branch 这个修改对查看带高亮的大文件会有性能提升:

For those who’re not familiar with this branch, it changes the way overlays are stored in a buffer: instead of keeping them in naïve singly-linked lists, it keeps them in balanced binary trees, so as to replace an O(N) complexity with O(log N). This way Emacs should not get sluggish even with millions of overlays (of course, if a given buffer position is covered by a million overlays, it’ll still be sluggish when operating around that position).

但我还没去跟旧版做对比。

不过倒是越来越严格了,例如以下代码:

(cl-defmethod nerd-line-segment ((_ (eql buffer-name)) &optional max med min face)
  "Buffer name segment."
  (when (cl-call-next-method _ max med min face)
    ...))

以前只是编译期告警 argument ‘_’ not left unused,现在运行期也会告警了,我前两天编译的版本还不会。

1 个赞
git pull  
make bootstrap

来尝尝鲜看看

期待你的体验报告

昨天编译最新的master分支,没打开native-comp特性。使用上没感觉快或者慢,也没报错。

哇,感谢分享,这就去编译一个

我config 参数

./configure --with-native-compilation  --with-pgtk --with-rsvg  --with-json --without-pop

没啥特别的感觉 :rofl:。要写专门的benchmark吗,我lisp学的还不到家。哈哈哈哈

你们是想问作者吗?我不是noverrlay作者呀 :joy:

弱弱地请教下,font lock会受益吗,或者换个问法font lock也是overlay实现的吗。我关了font lock mode但是symbol overlay还是可以用的,所以貌似不是一个东西。

内置的font lock不是overlay实现的, 但是很多通过外部lsp实现的语法高亮是overlay实现的, 此时overlay数量巨大, 导致emacs卡顿, 记得本分支最初就是针对这种情况开发的

这样的话对各种展示 indentation guide 的包应该有点帮助, 我记得之前大部分都因为 overlay 有些性能问题, 有些用 font-lock 做 workaround 效果也不特别好. 这类 mode 感觉差不多是 overlay 密度最高的了.

我记得 font lock 不是用 overlay 的。印象中 overlay 特别多的,首先就是 org-mode,或许应该咨询一下论坛里面有很多大型 org 文件的用户

用了个 overlay 比较多的 org 文件测试了下,

(length (overlays-in (point-min) (point-max)))  ;;=>4110

确实是流畅了点,但感觉提升幅度不大(不知道是不是心理作用

可能数量级还是比较小

1 个赞

更新后遇到了个和 overlay 有关的 bug ,不知道是否相关。

Peek 2022-10-31 21-09

如上图,org-capture 会打乱 org-ellipsis 的 overlay,重新 cycle 一下就可以恢复。大家有遇到这种情况吗?

emacs-repository-version
;; =>"a691e811e23dee48674e9e0716429074fdbe3d7b"

确实有这个问题,你可以给 Emacs 报个 bug

Kill buffer 后重新打开可以恢复:

我的是 macOS 编译的这个 commit:

但我在 emacs -Q 没法重现,估计是和其他包冲突了。

不是,font lock 用 string attribute 实现的

这代码本来就有问题吧,想要忽略 _ 随便传个参数就用 nil,想要传 _ 的内容就该把 _ 改个名字

我上面的演示就是用 emacs -Q 重现的。重现步骤:

org 文件

* DONE test
CLOSED: [2022-10-31 Mon 18:27]
:LOGBOOK:
- State "DONE"       from "TODO"       [2022-10-31 Mon 18:27]
:END:
* DONE test
CLOSED: [2022-10-31 Mon 18:27]
:LOGBOOK:
- State "DONE"       from "TODO"       [2022-10-31 Mon 18:27]
:END:
* DONE test
CLOSED: [2022-10-31 Mon 18:27]
:LOGBOOK:
- State "DONE"       from "TODO"       [2022-10-31 Mon 18:27]
:END:
* DONE test
CLOSED: [2022-10-31 Mon 18:27]
:LOGBOOK:
- State "DONE"       from "TODO"       [2022-10-31 Mon 18:27]
:END:

代码

(setq org-capture-templates
      '(("l" "test" entry (file "path to org")
           "* %?"
           :prepend t
           :empty-lines 0)))

需要用 org-cycle 转成 overview (折叠大纲)视图,然后在当前 buffer org-capture

因为你这里没有 overlay (org-ellipsis,默认是 ... ),你把 headline 折叠起来就可以复现了。

1 个赞

是的,折叠起来就有问题了。 可以重现,报 Bug 吧