Hi Alexei Alexandrov, you wrote:

> Hi Bram et al.,
> 
> I'm doing some performance investigations of Vim code trying to understand
> whether there are any possibilities to improve it.

I've also noticed that Vim spends somewhat significant time on startup loading 
spell files (I have 2 languages in my .vimrc: set spelllang=en,ru). The time is 
mostly spent in EnterCriticalSection/LeaveCriticalSection with getc() upper the 
stack. The reason for this is CRT blocking since the runtime is multithreaded. 
It's Windows, but on Linux it should be similar.

As far as I understand, Vim doesn't access the spell file from multiple 
threads. Thus, the situation can be improved a lot: on Linux by using 
getc_unlocked. On Windows, starting VS 2005 there is a function _getc_nolock. 
Before VS 2005 this function can be emulated by macro:

#define _getc_nolock(_stream) (--(_stream)->_cnt >= 0 ? \
                              0xff & *(_stream)->_ptr++ : _filbuf(_stream))

By switching to non-blocking getc() in spell.c I was able to reduce Vim startup 
time from about 0.9 seconds to about 0.7 seconds.

-- 
Alexei Alexandrov

Reply via email to