merge calls to KateView::updateView

Review Request #103657 - Created Jan. 9, 2012 and submitted

Information
Milian Wolff
kate
Reviewers
kate
cullmann, dhaumann
improve performance of kate by merging calls to KateView::updateView

When reloading a file e.g. this function is eventually called more than five times from very different places. To speed things up, we now start a singleshot 10ms timer that merges these calls into a single one, prevent less useless calls to this function.

NOTE: KateView already has delayedUpdateOfView and slotDelayedUpdateOfView via a QueuedConnection with the following comment:
// queued connect to collapse view updates for range changes, INIT THIS EARLY ENOUGH!

this is *not* correct - a queued connection will *not* collapse view updates and the function will still be called N times for N calls of delyedUpdateOfView. To my knowledge one has to use a timer to actually "merge" calls. I think my here proposed patch could be extended to cleanup/remove delayedUpdateOfView and slotDelayedUpdateOfView
loaded a big file, reloaded it.

i'll add some hard numbers eventually just don't have any at hand right now. Note that I've found this "bottleneck" via VTune. Anyhow, I think it's also easy to show this effect via simple QTime timing of updateView. I'll provide numbers later.

so, here are the numbers, note: loaded document is kate/part/document/katedocument.cpp

# without the patch:

- startup: 28 calls to KateViewInternal::updateView(), accumulated inclusive cost: ~62ms
- reload (F5): 14 calls to KateViewInternal::updateView(), accumulated inclusive cost per reload averaged over 10 reloads: ~34ms

# with the patch:

- startup: 16 calls to KateViewInternal::updateView(), accumulated inclusive cost: ~31ms
- reload (F5): 6 calls to KateViewInternal::updateView(), accumulated inclusive cost per reload averaged over 10 reloads: ~13ms

the timings are done by wrapping the body of KateViewInternal::updateView() with this code:

  static int elapsed = 0;
  QTime t;
  t.start();

...

  elapsed += t.elapsed();
  qDebug() << elapsed;

so yeah, I conclude that this patch makes reloading spent ~3x less time updating the view for this simple case. startup should also spent ~2x less time updating the view.
Milian Wolff
Christoph Cullmann
Commit Hook
Milian Wolff
Review request changed

Status: Closed (submitted)

Loading...