Incredibly slow on write
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- vim
- 领域
- performance, tooling
调研方向
使用 issue 中描述的最小 vimrc 和保存/关闭性能分析流程重现该延迟。首先跟踪 FormatCode、codefmt#FormatBuffer() 和 maktaba#syscall#Call();完成的标准是保存这个 200 行的 TypeScript 文件不再产生所报告的数秒延迟。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Recently upgraded vim, and I noticed that vim basically froze every time I wrote a file. I opened a typescript file with about 200loc and profiled using this set of commands: https://stackoverflow.com/a/12216578/3269537
To profile I just opened the file and saved it, then closed the file.
Output:
FUNCTIONS SORTED ON TOTAL TIME count total (s) self (s) function
9 5.210759 0.000624 maktaba#function#Call()
2 2.642967 0.000312 codefmt#FormatBuffer()
3 2.611224 0.000173 maktaba#syscall#Call()
3 2.610018 0.000436 <SNR>80_DoSyscallCommon()
3 2.605518 0.000057 maktaba#function#Apply()
3 2.603859 0.001205 maktaba#syscall#DoCall()
2 2.402088 0.001135 42()
1 1.472221 0.000255 <SNR>33_FormatBufferAndSetRepeat()
1 1.171017 0.000016 <SNR>32_FmtIfAutoEnabled()
2 0.240567 0.000527 <SNR>38_GetFormatter()
2 0.239915 0.000078 <SNR>38_IsAvailable()
2 0.239817 0.000679 40()
2 0.020809 0.001005 maktaba#buffer#Overwrite()
2 0.019677 0.019450 maktaba#python#ImportModule()
7 0.004788 0.000730 maktaba#syscall#GetCommand()
24 0.003627 0.001727 maktaba#string#Strip()
5 0.002999 0.000466 codefmt#formatterhelpers#ResolveFlagT
oArray()
2 0.002801 0.000086 maktaba#syscall#WithCwd()
2 0.002715 0.000076 maktaba#syscall#And()
116 0.002186 0.001214 maktaba#ensure#IsString()
notice that maktaba takes ~5s and codefmt takes ~2.5
To Reproduce
Minimal vimrc:
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'google/vim-maktaba'
Plugin 'google/vim-codefmt'
Plugin 'google/vim-glaive'
call vundle#end()
call glaive#Install()
" Set up useful defaults for codefmt.
augroup autoformat_settings
autocmd FileType bzl AutoFormatBuffer buildifier
autocmd FileType c,cpp,proto,arduino AutoFormatBuffer clang-format
autocmd FileType dart AutoFormatBuffer dartfmt
autocmd FileType go AutoFormatBuffer gofmt
autocmd FileType gn AutoFormatBuffer gn
autocmd FileType html,css,sass,scss,less,json,vue,javascript,javascriptreact,typescript,typescriptreact AutoFormatBuffer prettier
autocmd FileType java AutoFormatBuffer google-java-format
autocmd FileType python AutoFormatBuffer yapf
autocmd FileType rust AutoFormatBuffer rustfmt
augroup END
Glaive codefmt plugin[mappings]
autocmd BufWritePre * FormatCode
Expected behavior
Previously this was not nearly this slow. I was expecting a non-noticeable latency on save.
OS (version)
Ubuntu 20.04.3 LTS
Additional context
vim version: VIM - Vi IMproved 9.0 (2022 Jun 28, compiled May 10 2022 08:40:37)
- 主要语言
- Vim Script
- 星标
- 1.1k
- 派生
- 102
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
google/vim-codefmt 的其他 Issue
-
enhancement
难度 1/5 1-3 小时 新手友好度 68/100
google/vim-codefmt#53 ·
-
Add meson format 未关闭new formatter
难度 3/5 1-2 天 新手友好度 45/100
google/vim-codefmt#243 ·
-
难度 3/5 1-2 天 新手友好度 52/100
google/vim-codefmt#240 · 1 条评论 ·
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
google/vim-codefmt#234 · 2 条评论 ·
-
难度 1/5 1-3 小时 新手友好度 45/100
google/vim-codefmt#222 · 3 条评论 ·
查看 google/vim-codefmt 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
-
[Documentation Request] vLLM kv_load_failure_policy doesn't apply to load failures in L2 adapters 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 75/100
components-web-app/docs#73 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
jenkinsci/blueocean-plugin#5417 ·
-
难度 2/5 1-3 小时 新手友好度 75/100