Vim author creates branch Vim9 to improve Vim’s performance

Bram Moolenaar, the founder of the Vim Editor, originally developed Vim as an “enhanced version” of the Vi editor, but now he wants to improve Vim itself through an experimental branch called Vim9. Bramm9 is an experimental branch of Vim that aims to explore ways to make Vim scripts better and faster, says Bramlena Molenaar.

This is also the most demanding feature requirement for developers, in addition to Popup Windows and Text Properties.

In order to execute the Vim script more quickly, Bram thinks a lot and concludes that the way the current call and execute functions (with dictionaries for parameters and local variables) is never going to be quick. Vim’s performance will be significantly improved if it is able to make it twice as fast. After all, the overhead of calling and executing each row of functions is very high.

Bram argues that only a new method similar to the old method that defines functions with different properties can make the speed faster:

Arguments can only be used by name, not by a: dictionary or a:000 list

Local variables are not available in l: dictionary

Address some speed-affecting issues, such as exception handling details

For the above idea, Bram provides proof-of-concept code. So far, vim takes five seconds to run a looped Vim script, and Vim9 can run it in 0.07 seconds, the same time as the Lua script, and faster than Python.

let sum = 0  for i in range(1, 2999999)    let sum += i  endfor how time in sec Vim old 5.018541 Python 0.369598 Lua 0.078817 Vim new 0.073595

In more relevant snippets, Vim9 can run the script in 0.19 seconds, while Vim can run 0.85 seconds.

let totallen = 0  for i in range(1, 100000)    call setline(i, ‘    ‘ .. getline(i))    let totallen += len(getline(i))  endfor how time in sec Vim old 0.853752 Python 0.304584 Lua 0.286573 Vim new 0.190276

See its GitHub repository for specific implementation ideas and details on Vim9, which is validated and incorporated into Vim.

Add a Comment

Your email address will not be published. Required fields are marked *