Speeding Vim diff, maybe?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Speeding Vim diff, maybe?

François Pinard
Hi, people.

Not a big matter, and the issue is already resolved for me.  I merely
asking now, trying to learn "for the next time" :-).

I had a few pair of similar files to handle, and chose `vi -d' to do
so.  In each pair, each file was between 20 Megs to 40 Megs.  Each pair
had a few thousands of small differences.  I had less than a dozen "dp"
commands (pushing the difference from one file into the other) to do.
A previous batch program identified the line number of the spurious
differences, so finding the correct difference in Vim was a simple
matter of commands like "279764G", which were effected very quickly.

However, after each "dp", the CPU burned maye one or two minutes, and
only then, the display got updated.  So, it has been a bit longish
overall, waiting after each "dp".  Could something could have been
turned off for Vim to do its job faster?  In any case, I'm quite
satisfied of the ease with which Vim helped me at this bit of work.

--
Fran?ois Pinard   http://pinard.progiciels-bpi.ca
Reply | Threaded
Open this post in threaded view
|

Re: Speeding Vim diff, maybe?

Tim Chase-2
> Could something could have been turned off for Vim to do its
> job faster?


Well, prime suspects include

        -disable syntax highlighting
        -set your undo-levels to 0

which may help speed up interactions.

        :syntax off
        :set undolevels=0

should do the trick.

if it's still slow, at 20-40 megs a pop, you may be up ye olde
proverbial creek without ye olde proverbial paddle :)

HTH,

-tim




Reply | Threaded
Open this post in threaded view
|

Re: Speeding Vim diff, maybe?

François Pinard
[Tim Chase]

> >Could something could have been turned off for Vim to do its job
> >faster?

> Well, prime suspects include

> -disable syntax highlighting
> -set your undo-levels to 0

> which may help speed up interactions.

> :syntax off
> :set undolevels=0

> should do the trick.

Thanks for these tips, which sent me back to the Vim documentation.  It
seems that the undo mechanism saves the current folds, and since the
diff mode of Vim creates a lot of folds on my big files, it sounds only
logical that saving them requiress time.  It seems that

    :set undolevels=-1

could even be better in such cases, as the "=0" setting still saves one
level of undo.

> if it's still slow, at 20-40 megs a pop, you may be up ye olde
> proverbial creek without ye olde proverbial paddle :)

Wow!  I needed a dictionary to decipher and enjoy the above sentence,
and even then, there undoubtedly is more flavour in it that what can
taste my poor knowledge of English :-).

--
Fran?ois Pinard   http://pinard.progiciels-bpi.ca
Reply | Threaded
Open this post in threaded view
|

Re: Speeding Vim diff, maybe?

Tim Chase-2
>> :set undolevels=0
[snip]

> logical that saving them requiress time.  It seems that
>
>     :set undolevels=-1
>
> could even be better in such cases, as the "=0" setting still saves one
> level of undo.

Silly me...I should have caught that.  Yes, setting to -1 would be even
better.

>>if it's still slow, at 20-40 megs a pop, you may be up ye olde
>>proverbial creek without ye olde proverbial paddle :)
>
> Wow!  I needed a dictionary to decipher and enjoy the above sentence,
> and even then, there undoubtedly is more flavour in it that what can
> taste my poor knowledge of English :-).

You'll have to excuse my poor excuse for mocking "olde" English.  Often
on pubs/taverns/etc one will find signs reading "Ye Olde Pub" or what
have you, in an attempt to sound quaintly like you've stepped out of
King Arthur's world.  The "ye" is a corruption of "the" (where the "th"
was written with the "thorn" character which looks a bit like the letter
"y").  I'm not sure where the suffixed "e" originated, changing "old" or
"olden" to "olde".  In addition, there's an
proverb/idiom/saying/aphorism describing a bad situation as being "up a
creek without a paddle".

Un-old-english-ified: "If it's still slow, at 20-40 megs a pop, you may
be up a creek without a paddle"...as in, "there might not be much you
can do about it."

-tim


Reply | Threaded
Open this post in threaded view
|

Re: Speeding Vim diff, maybe?

Charles E Campbell Jr
In reply to this post by François Pinard
Fran?ois Pinard wrote:

>I had a few pair of similar files to handle, and chose `vi -d' to do
>so.  In each pair, each file was between 20 Megs to 40 Megs. ...snip
>
>However, after each "dp", the CPU burned maye one or two minutes, and
>only then, the display got updated.  So, it has been a bit longish
>overall, waiting after each "dp".  Could something could have been
>turned off for Vim to do its job faster?...snip
>  
>

Hello!

May I suggest putting in your <.vimrc>:

" Augroup LargeFile: for large files: turn undo off, etc (based on vim
tip #611) {{{2
let g:LargeFile= 10    " in megabytes
let g:LargeFile= g:LargeFile*1024*1024
augroup LargeFile
  au BufReadPre *
  \ let f=expand("<afile>") |
  \  if getfsize(f) >= g:LargeFile |
  \  let b:eikeep= &ei |
  \  let b:ulkeep= &ul |
  \  set ei=FileType |
  \  setlocal noswf bh=unload |
  \  let f=escape(substitute(f,'\','/','g'),' ') |
  \  exe "au LargeFile BufEnter ".f." set ul=-1" |
  \  exe "au LargeFile BufLeave ".f." let &ul=".b:ulkeep."|set
ei=".b:eikeep |
  \  exe "au LargeFile BufUnload ".f." au! LargeFile * ". f |
  \  echomsg "***note*** handling a large file" |
  \ endif
augroup END

That will do a number of things, including turning undo recording off
and syntax highlighting off;
both of these tend to make vim slow down when its deals with large
files.  Large files are set up
as >= 10MBytes, but that's easily changed (see g:LargeFile).

Regards,
Chip Campbell