equalsraf / neovim-qt

Neovim client library and GUI, in Qt5.
https://github.com/equalsraf/neovim-qt/wiki
ISC License
1.83k stars 171 forks source link

Excessive disk I/O when writing shada file with active vimtex plugin #373

Open x49 opened 6 years ago

x49 commented 6 years ago

Issue

When closing neovim-qt after editing a latex file with the vimtex plugin (https://github.com/lervag/vimtex) active, excessive disk i/o is noticeable. This process takes several seconds. This behaviour is not present when editing the same file with the same plugins directly in nvim (console).

MWE

Have files nvimrc with

set nocompatible

" Load Vimtex
let &rtp  = '~/.config/nvim/plugged/vimtex,' . &rtp
let &rtp .= ',~/.config/nvim/plugged/vimtex/after'

filetype plugin indent on
syntax enable

and main.tex with

\documentclass{minimal}
\begin{document}

Test

\end{document}

Delete any old shada files, for me this is rm ~/.local/share/nvim/shada/*. Open the file with nvim -u nvimrc main.tex. Edit something, I added some words after Test. Then :wq. nvim exits quickly. Delete shada again, then open the same file with nvim-qt main.tex -- -u nvimrc and edit it again. Then :wq. nvim-qt thrashes disk and takes a couple of seconds.

I traced the accessed files with fatrace. For nvim, accessing the shada file starts at line 525, for nvim-qt at line 1135. nvim-qt shows many more uses of the shada file. The noise my hard drive makes when those accesses occur lets me know that that is what is causing the problem ;).

nvim.fatrace.txt nvim-qt.fatrace.txt

Software:

clason commented 6 years ago

I also noticed that neovim-qt leaves *.tex~ (and tey~ etc.) files behind after closing even with set nobackup, which nvim doesn't. May be related?

equalsraf commented 6 years ago

Disk trashing on a cold start could be nvim-qt loading the Qt shared libraries. Its strange that it would happen on exit.

If the problem is in fact writing to the shada file, can you take a look at it?

A quick test is to disable shada completely nvim -i NONE

Going further you can have a look at the contents of the shada file, e.g. in vimscript (taken from :h msgpackparse)

let fname = expand('~/.local/share/nvim/shada/main.shada')
let mpack = readfile(fname, 'b')
let shada_objects = msgpackparse(mpack)
echo shada_objects ...

I also noticed that neovim-qt leaves *.tex~ (and tey~ etc.) files behind after closing even with set nobackup, which nvim doesn't. May be related?

neovim-qt does not handle those files at all, it is always the nvim process doing that in the background.

x49 commented 6 years ago

Disabling shada does indeed make the problem go away. Here's the contents of the shada files. I openend the files as in the initial post, then

<down>4
a " type something
<Esc>:wq

From nvim

[1, 1516344346, 72, {'pid': 8844, 'version': 'NVIM v0.2.2', 'encoding': 'utf-8', 'max_kbyte': 10, 'generator': 'nvim'}, 8, 1516344321, 33, {'f': '/home/me/tmp/
vimtex/main.tex'}, 8, 1516344346, 39, {'c': 13, 'f': '/home/me/tmp/vimtex/main.tex', 'l': 5}, 3, 0, 3, [''], 10, 1516344346, 39, {'c': 13, 'f': '/home/me/tmp/v
imtex/main.tex', 'l': 5}, 10, 1516344331, 42, {'c': 14, 'f': '/home/me/tmp/vimtex/main.tex', 'l': 5, 'n': 94}, 10, 1516344327, 42, {'c': 13, 'f': '/home/me/tmp
/vimtex/main.tex', 'l': 5, 'n': 46}, 11, 1516344327, 39, {'c': 13, 'f': '/home/me/tmp/vimtex/main.tex', 'l': 5}, 4, 1516344346, 6, [0, 'wq']]

From nvim-qt

[1, 1516344452, 72, {'pid': 9403, 'version': 'NVIM v0.2.2', 'encoding': 'utf-8', 'max_kbyte': 10, 'generator': 'nvim'}, 8, 1516344444, 33, {'f': '/home/me/tmp/
vimtex/main.tex'}, 8, 1516344450, 39, {'c': 15, 'f': '/home/me/tmp/vimtex/main.tex', 'l': 5}, 8, 1516344452, 39, {'c': 15, 'f': '/home/me/tmp/vimtex/main.tex',
 'l': 5}, 3, 0, 3, [''], 10, 1516344452, 39, {'c': 15, 'f': '/home/me/tmp/vimtex/main.tex', 'l': 5}, 10, 1516344449, 42, {'c': 16, 'f': '/home/me/tmp/vimtex/ma
in.tex', 'l': 5, 'n': 94}, 10, 1516344449, 42, {'c': 15, 'f': '/home/me/tmp/vimtex/main.tex', 'l': 5, 'n': 46}, 11, 1516344449, 39, {'c': 15, 'f': '/home/me/tm
p/vimtex/main.tex', 'l': 5}, 4, 1516344450, 6, [0, 'wq']]
gagbo commented 6 years ago

I encountered the issue as well. One side-effect is that if I try to shutdown my computer (Fedora rawhide, Plasma 5.12.90 but I had the issue with stable F28/Plasma 5.12 and F28/Openbox) :