The steps to reproduce:
a
and b
(it doesn't matter if they are the same or different)vim -N -u NONE a
, then do :g/4/d
.vim -N -u NONE -d a b
, then do :g/4/d
in one of the buffer. it's much slower. Also undo is really slow too.—
Reply to this email directly or view it on GitHub.
To switch off highlighting you can use :syn off
and then to re-enable it :syn enable
.
Hi, I've discovered that most of the time is used in diff_infold
. Here's the flamegraph: https://img.vim-cn.com/1f/223148527b0787a5cb427ed713ab46a513859f.svg
—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
set nofoldenable
doesn't improve things any, but set foldmethod=manual
does the trick. (I've been testing with 8.0..42, and have actually been doing _windo_ set foldmethod=manual
. Not sure whether it actually matters, though, what state the other windows are in.)
@brammool wrote:
Unfortunately Vim doesn't know if it's faster to switch off folding, apply the changes, then switch folding back on. With a small change it could be much slower.
Vim could make that decision after the first (line-marking) pass, once it knows how many lines need to be touched.
The thing is, once that hot spot (which is specifically diff_infold
, as @lilydjwg says) has been dealt with, another one rears its head: diff_mark_adjust_tp
. This one isn't nearly as bad, but it's still painful once files get large enough. Can that also be disabled temporarily?
FYI: Empirical results from my very limited testing -- which consists of vimdiffing two identical large files of consecutive integers and doing :g/0$/d
in one of them -- show diff_infold
scaling at something like O(D^3) (where D is the number of lines being deleted). The number of calls scales at O(D^2), and the CPU per call scales at about O(C^1.5) (where C is the number of calls made). Yup: as the number of deletions increases, diff_infold
is called more times per deletion, and each one of those calls gets more expensive. Not sure whether that's surprising or not, to folks who know the code. I'm also not sure how important it is in practice, if folding can indeed be temporarily disabled for large values of D.
diff_mark_adjust_tp
is called exactly once per deletion, i.e. it's precisely O(D), but again, its CPU usage grows, at about O(C^2).
(If these results point to things that could use improvement independent of the :g
situation, let me know and I'll file separate issues for them.)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
I think this has been fixed by Patch 8.1.1922.
Closed #603.