rickhowe / diffchar.vim

Highlight the exact differences, based on characters and words
http://www.vim.org/scripts/script.php?script_id=4932
MIT License
217 stars 10 forks source link

High CPU usage on large input files #13

Closed aswna closed 5 years ago

aswna commented 6 years ago

Hi, is it possible to improve the performance of this plugin (f.i.: highlight a smaller) working on larger input files? Symptom: CPU usage is 100% when comparing two ~40MB (CSV) files differing only in the data in a specific column. Vim remains unresponsive even after showing the diff (hence cannot even navigate or quit vim). It seems, 80.000 lines in the files are enough the reproduce this (on my setup). The lines are ~80 characters long, separated in ~10 columns.

rickhowe commented 6 years ago

Hi, Thank you for asking . Yes, I have found a performance issue like that in vim when I tried to do my best in the latest version 7.6. Actually, vim always searches all the previous highlight IDs if the new ID is duplicated or not when it is added. So if so many IDs has been defined, it takes a lot of time.

As a workaround, I would recommend to separate lines and do diff:

  1. open your two files in vim
  2. : let t:DiffModeSync=0
  3. : windo diffthis
  4. : 1,5000SDChar
  5. : %RDChar
  6. : 5001,10000SDChar
  7. : %RDChar
  8. ..... You can try to change with other number of lines.
rickhowe commented 6 years ago

If you can compare line by line (same line) between your two files, try this simple script. This will make a diff only on the displayed lines on a window, and continue to do each time you scroll the page.

  1. open your two files
  2. : let t:DiffModeSync = 0
  3. : windo diffthis
  4. : windo set nodiff
  5. : so DCharOnScroll,vim
  6. try to move cursor or scroll

DCharOnScroll.zip