Incredibly slow on write
まだ誰も着手していません。
評価
- 難易度
- 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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google/vim-codefmt のほかの issue
-
Write a codefmt FAQ オープン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 件 ·
-
Add `:CodefmtInfo` command to report diagnostics to help users check config / diagnose problems オープンenhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
google/vim-codefmt#234 · コメント 2 件 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 45/100
google/vim-codefmt#222 · コメント 3 件 ·
google/vim-codefmt の issue をすべて見る
似ている issue
-
🎙️ task - perf(jest): source keyrack once per run in globalSetup, not per suite file (~25s each) オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
brave/brave-browser#59300 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Borewit/music-metadata#2755 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100