Luc Hermitte wrote:

> I've observed a poor performances issue when using glob(starstar/whatever).
> I know this is a known issue, I just had to look at the first lines of 
> unix_expandpath().
> 
> And yet, we could do better. Much better.
> 
> I've run a simple test case in callgrind:
> 
> > valgrind --tool=callgrind ./vim -U NONE -u NONE -c "echo 
> > glob('~/.vim/**/tags')" -c q
> 
> On my current machine, I see vim_regexec() and vim_regcomp() executed 14036 
> times, and taking respectively 41.72% + 15.67% of unix_expandpath() (lr) 
> cycles measured by callgrind.
> 
> Investigating further, I've seen that simply by caching `regmatch.regprog` 
> when `starstar` is true and `e-s==2`, vim_regcomp() is executed now only 
> **once** on my test case. From 363879003 cycles in unix_expandpath() I do 
> down to 291294681. This looks like a good start.
> 
> 
>     static regprog_T *reg_starstar = NULL;
>     if (!reg_starstar) {
>       reg_starstar = reg_starstar_compute();
>     }
>     ...
>     if (starstar && (e-s == 2))
>     {
>       onlystarstar = TRUE;
>       regmatch.regprog = reg_starstar;
>       if (regmatch.regprog == NULL) {
>           vim_free(buf);
>           return 0;
>       }
>     } else { old code, rearranged, of course }
> 
> And I wonder. Do we really need to apply regmatch when we know we are
> in a "starstar" situation? Can't we simply go down to the next
> sub-directory?

The path expension code is complex, has been buggy, and I'm sure it can
be improved.  However, if we make changes it's also easy to break.  Thus
we should make sure we have good test coverage befor making changes.

> BTW, on another topic, I've also executed 
> 
> > vim -U NONE -u NONE -c "echo glob('~/.vim/**5/tags')" -c q
> 
> which yields no result on v 8.0.502, un-patched, and on my patched v8.0.563
> If I understand the documentation correctly, this looks like a bug.

Depends on how you use it.  The spec 

        When non-wildcard characters are used right before or after "**"
        these are only matched in the top directory.  They are not used
        for directories further down in the tree.



-- 
GUARD #1:  Where'd you get the coconut?
ARTHUR:    We found them.
GUARD #1:  Found them?  In Mercea?  The coconut's tropical!
ARTHUR:    What do you mean?
GUARD #1:  Well, this is a temperate zone.
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- [email protected] -- 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui