lsp-bridge 在 macOS 上比 Linux 卡

各位有没有发现 lsp-bridge 在 macOS 上运行要更缓慢和卡顿。

我的设备是 10 核心的 M1 Pro 的 MacBook Pro。Emacs 是从官网下载源码用native compilation 参数编译的。

同样的配置文件,lsp-bridge 的弹出和列表在另一台配置显著比我笔记本低一截的 Linux 电脑上却更流畅。甚至是我自己的macbook 上,如果在 debian 虚拟机里面运行 emacs + lsp-bridge 也比直接在 macOS 上要流畅许多。用 profiler 得到的结果如下:

    1217  72% - redisplay_internal (C function)
     140   8%  - eval
     132   7%   + lsp-bridge--mode-line-format
       8   0%   + if
       5   0%  + jit-lock-function
       5   0%    file-remote-p
     305  18% + command-execute
      92   5% + timer-event-handler
      43   2% + ...
      15   0% + lsp-bridge-monitor-post-command
       3   0% + #<interpreted-function 6FE>

这个差距在使用 rust-analyzer 分析rust 项目的时候还不明显,但是用 texlab 来读取一些较大的 latex 项目就很明显了, 比如键入 $\lam$ 之后要等一两秒才会弹出\lambda,而在 linux 上就是立刻弹出。使用 lsp-bridge-profile-dump 然后分析生成的 lsp-bridge.prof得到如下:

所以我想应该不是 lsp-bridge 的 python 部分运行慢。

当然即使如此,lsp-bridge 依然要比 lsp-mode 要快。

另外,EAF 在 macOS 上也要卡很多,在使用 EAF PDF Viewer 时候,如果拖动 emacs 窗口,那么原有内容会停留在原处一段时间,然后才跟过去到新的位置。为此我已经放弃在 macOS 上使用 EAF 了,看PDF还是用 skim 。

嗯… Mac OS 上几乎所有 Emacs 插件都慢了些,很大程度上和 Mac OS 的反病毒策略有关。

同样的配置,在 WSL 里启动只要 0.22s,在 mac 要 0.32s。所以 mac 比 linux 要稍微慢一点我并不意外。当然 mac 的 emacs 速度再慢也就是稍稍慢,和 windows 比也算好的多得多了。

而且还有使用1天到1周后补全/文档框占满整个frame显示的诡异bug :smiling_face_with_tear: 要不fsf怎么说,支持win/mac只是让你在不free的平台上尝一尝,来作为最终迁到free平台上的过渡 呢

你是lsp-bridge最新版吗?

最近修复了一个rust inlay依赖redisplay的性能问题。

同时建议emacs -Q做横向对比,并确保lsp-bridge日志选项不要打开,打开日志影响性能。

是 ARM mac 么?

我也遇到了一样的问题,我并不认为是因为 macos 天然就是更卡。因为我有 2 台设备,设备 1 是 wsl, 设备 2 是 macbook. macbook 由于更好的芯片,启动时间是 6-7 s, wsl 上则是 12s 左右。 而且用下来也会感觉 macbook 比 wsl 更为流畅。 但我前些天试了试 eaf pdf 组件,wsl 上不说多快,至少是可以用的,macbook 我试了一次,太卡了我就放弃了。

有用arm macos Sequoia GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.4.0, NS appkit-2575.50 Version 15.4.1 (Build 24E263)) of 2026-01-17 (lsp-bridge-python-command “/opt/homebrew/Cellar/[email protected]/3.14.2/bin/python3”)

出现如下的错误 Don’t know how to run. Try “help target”. No stack.

Process lsp-bridge exited abnormally with code 1 Don’t know how to run. Try “help target”. No stack.

Mac下lsp-bridge我用的python3.14有问题,用python3.13没问题。

lsp-bridge-python-command 变量的值为如下的值,换成3.13还是一样的问题

/Users/helia/data/python-envs/lsp-bridge/.venv/bin/python3 --version Python 3.13.11

(use-package lsp-bridge
  :load-path (lambda() (get-load-path "lsp-bridge"))
  :defer 1
  :config
  (setq lsp-bridge-python-command "/opt/homebrew/bin/python3-emacs")
  ;; use lsp-bridge-toggle-sdcv-helper to turn the function on
  (setq acm-backend-search-sdcv-words-dictionary "/Users/kap/.stardict/dict/stardict-kdic-ec-11w-2.4.2/kdic-ec-11w")

  (setq lsp-bridge-markdown-lsp-server "vale-ls")
  (defun lsp-bridge-set-project-path ()
  	(interactive)
  	(setq lsp-bridge-get-project-path-by-filepath
  		  (lambda (filepath)
  			(save-match-data
  			  (and (string-match (concat default-directory "\\([^/]*\\)") filepath)
  				   (match-string 0 filepath))))))

  (require 'yasnippet)
  (yas-global-mode 1)
  (global-lsp-bridge-mode)
  (setq lsp-bridge-c-lsp-server "ccls")
  (setq acm-frame-background-light-color "#439c6b")
  ;;(setq lsp-bridge-enable-auto-format-code t)
  (setq acm-enable-codeium nil)
  (setq acm-enable-capf t)
  (setq lsp-bridge-remote-start-automatically t)
  )

这是我的配置。 你看看 lsp-bridge 日志?

lsp-bridge 是多线程的,不会卡的, 你卡的原因是你开了 capf ,然后你那些 capf 后端导致的卡

我的配置在windows/linux下都可以正常使用,只是搬到macos中就出错了,开了log和debug但是没有看到其他的错误。

我直接用 python执行 lsp-bridge.py的时候出现如下错误,换成uv安装3.13的时候也是同样的错误:

/opt/homebrew/Cellar/[email protected]/3.14.2/bin/ [stable] python3 ~/.emacs.d/.local/straight/repos/lsp-bridge/lsp_bridge.py

* Running lsp-bridge on remote server. Access files with 'lsp-bridge-open-remote-file' or 'find-file /docker:...'
^CTraceback (most recent call last):
  File "/Users/helia/.emacs.d/.local/straight/repos/lsp-bridge/lsp_bridge.py", line 1106, in <module>
    LspBridge(sys.argv[1:])
    ~~~~~~~~~^^^^^^^^^^^^^^
  File "/Users/helia/.emacs.d/.local/straight/repos/lsp-bridge/lsp_bridge.py", line 130, in __init__
    self.event_loop.join()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/[email protected]/3.14.2/Frameworks/Python.framework/Versions/3.14/lib/python3.14/threading.py", line 1133, in join
    self._os_thread_handle.join(timeout)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
KeyboardInterrupt
^CException ignored while joining a thread in _thread._shutdown():
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/[email protected]/3.14.2/Frameworks/Python.framework/Versions/3.14/lib/python3.14/threading.py", line 1583, in _shutdown
    _thread_shutdown()
KeyboardInterrupt: