Re: Statement reparsing

2018-02-22 Fir de Conversatie Bram Moolenaar

Jason Felice wrote:

> I've been thinking about the recent thread about vimscript and performance
> (after optimizing the heck out of a plugin that does a lot of text
> processing), and I'm curious about vim's reparsing of statements in
> functions and while loops and such for each execution.
> 
> Is there something about the syntax that prevents caching parses?  Or
> another mechanism?  Or is it just that nobody's stepped up to do this?  Or
> something else, maybe it's not a good idea?

I have been thinking about it many times, but never got to actually
start with it.  The idea would be to store the parser result somehow
(would depend on the command what to store).  And then associate it with
the saved raw line, so that it gets freed when no longer used.
Should work both for loops and for functions.

It will require more memory, but these days that's hardly something to
worry about.

It could be combine with more clever and generic parsing, but that is
going to be a lot of work.  Also, storing the parser output will require
more work, thus we need a benchmark to make sure there is enough gain.

-- 
"When I die, I want a tombstone that says "GAME OVER" - Ton Richters

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Statement reparsing

2018-02-21 Fir de Conversatie Nikolay Aleksandrovich Pavlov
2018-02-22 0:07 GMT+03:00 Jason Felice :
> I've been thinking about the recent thread about vimscript and performance
> (after optimizing the heck out of a plugin that does a lot of text
> processing), and I'm curious about vim's reparsing of statements in
> functions and while loops and such for each execution.
>
> Is there something about the syntax that prevents caching parses?  Or
> another mechanism?  Or is it just that nobody's stepped up to do this?  Or
> something else, maybe it's not a good idea?

What do you mean by “caching parses”? There is no virtual machine
executing bytecode, no JIT and no AST - there is *nothing* to cache.
To be able to cache something you first need that something to cache,
and this is exactly the problem. As I said I am currently working on
adding all of that (minus JIT as it would be too complex for me) (to
Neovim), but this is done slowly and this is guaranteed to introduce
incompatibilities: e.g.

- Incompatibilities of the latest expressions parser:
https://github.com/ZyX-I/neovim/blob/389e4fc40f8cee4fa7be7f427fea277674bb2d79/src/nvim/viml/parser/expressions.c#L6-L51.
- Extreme example of function definitions that is completely
impossible to parse with a proper parser:
https://github.com/neovim/neovim/issues/425. Note that the same
technique may be used for :if blocks, unlike function definitions I
could theoretically keep `:execute 'if'` support if I was to drop the
idea of parsing `if|cmd|endif` as `if(cmd)` rather then
`if;cmd;endif`, but I do not like the idea.
- Collection of incompatibilities of a first attempt to create a
parser (code from there may be reused, but resulting AST structures
appeared to be too complex and the whole parser was both recursive and
rather limited (e.g. would not be able to provide highlighting)):
https://github.com/neovim/neovim/issues/387.

>
> Thanks,
> -Jason
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Statement reparsing

2018-02-21 Fir de Conversatie Jason Felice
I've been thinking about the recent thread about vimscript and performance
(after optimizing the heck out of a plugin that does a lot of text
processing), and I'm curious about vim's reparsing of statements in
functions and while loops and such for each execution.

Is there something about the syntax that prevents caching parses?  Or
another mechanism?  Or is it just that nobody's stepped up to do this?  Or
something else, maybe it's not a good idea?

Thanks,
-Jason

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.