Saturday, September 13, 2014

Re: sorted file takes much longer to load

John Little wrote:

> On Friday, September 12, 2014 3:52:30 PM UTC+12, John Little wrote:
> > On Friday, September 12, 2014 2:35:40 AM UTC+12, Charles Campbell wrote:
> > > Have you tried profiling?
> >
> > Just did ...
>
> Then I found gprof -l. It's first couple of lines say
>
> % cumulative self self total
> time seconds seconds calls ns/call ns/call name
> 85.41 48.36 48.36 ml_updatechunk (memline.c:5035 @ 4d368d)
> 7.86 52.81 4.45 ml_updatechunk (memline.c:5033 @ 4d36eb)
>
> These are in a for loop:
>
> for (curline = 1, curix = 0;
> curix < buf->b_ml.ml_usedchunks - 1
> && line >= curline + buf->b_ml.ml_chunksize[curix].mlcs_numlines;
> curix++)
> {
> curline += buf->b_ml.ml_chunksize[curix].mlcs_numlines;
> }
>
> It appears that vim is walking its list of chunks (where it keeps lines) from the beginning, for each line of text already read when it changes encoding. I suspect there's several performance opportunities here:
> 1) The "last" chunk used by ml_updatechunk is saved in static variables. This mechanism seems to be not working.
> 2) In my case the vast majority of lines haven't changed, there's no need to update anything.
> 3) Something faster than a linear search might be possible.

All this just for just for being able to use the "go" command...
Well, and some other functionality that uses byte offsets.

Besides optimizing ml_updatechunk() for the use case of reading a large
file, another method would be to not keep anything updated until "go" is
actually used. I suspect most people don't use it at all. It will have
an impact on the first time "go" is used, but not more than what is
currently being done when reading a file.

--
You cannot have a baby in one month by getting nine women pregnant.

/// Bram Moolenaar -- Bram@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_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment