Skip to content

vim: [fileio] avoid quadratic copying when reading long lines - #21933

Closed
ayroblu wants to merge 1 commit into
vim:masterfrom
ayroblu:fileio-long-line
Closed

ayroblu wants to merge 1 commit into
vim:masterfrom
ayroblu:fileio-long-line

Conversation

@ayroblu

@ayroblu ayroblu commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

I was speeding up my vim plugins with the bot and noticed this peculiarity while opening large single line files where the memory usage is huge.

Apparently readfile() copies a partial line once per 1 MB read.

100 MB single-line file:

open time memory used
Before 460 ms 4273 MB
After 100 ms 335 MB

Same fix as neovim/neovim#42851.

Related: #15377

Problem:  readfile() copies a partial line once per 1 MB read.

Solution: grow the read buffer geometrically.
@chrisbra

Copy link
Copy Markdown
Member

thanks

@chrisbra chrisbra closed this in e8e1dc8 Nov 30, 2026
zeertzjq pushed a commit to ayroblu/neovim that referenced this pull request Dec 1, 2026
vim-patch:9.2.1436: reading a file with a very long line is slow

Problem:  readfile() copies a partial line once per 1 MB read.
Solution: Grow the read buffer geometrically.

closes:  vim/vim#21933
related: vim/vim#15377

vim/vim@e8e1dc8
zeertzjq pushed a commit to neovim/neovim that referenced this pull request Dec 1, 2026
vim-patch:9.2.1436: reading a file with a very long line is slow

Problem:  readfile() copies a partial line once per 1 MB read.
Solution: Grow the read buffer geometrically.

closes:  vim/vim#21933
related: vim/vim#15377

vim/vim@e8e1dc8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants