Skip to content

Improve performance #23

Merged
merged 8 commits into from Mar 22, 2019
Merged

Improve performance #23

merged 8 commits into from Mar 22, 2019

Conversation

donald
Copy link
Contributor

@donald donald commented Mar 22, 2019

Make (some) performance improvements.
Main feature: Redundant redraws are avoided.
This makes xdu usable for big files, too. (Fixed #21)

The startup time of xdu with big du outputs is longer than it
needs to be, because the tree is kept sorted while inserting new
nodes. Because of the locality of "du", we are likely to get
paths with the same prefix in order (e.g. "/a/b/c/x","/a/b/c/y",
"/a/b/c"). Each path is split into its components ("a","b",...) and
these are seached for in the tree to find the correct parent to insert
the new node. This search can greatly be reduced, if we insert new
nodes as the first child of the parent, because we are very likely
to search for exactly this component when we process the next entry.

Always add new nodes as first child of the parent node, sort the tree
once after the initial build.

Performance comparison
======================

This was done with a relative small data file (144857 lines) and
includes just the startup time (xmainloop disabled).

Before this commit:

         368.781008      task-clock (msec)         #    0.728 CPUs utilized
                 24      context-switches          #    0.065 K/sec
                  1      cpu-migrations            #    0.003 K/sec
              14561      page-faults               #    0.039 M/sec
         1345388200      cycles                    #    3.648 GHz
    <not supported>      stalled-cycles-frontend
    <not supported>      stalled-cycles-backend
         2267580465      instructions              #    1.69  insns per cycle
          527033055      branches                  # 1429.122 M/sec
            1899345      branch-misses             #    0.36% of all branches

        0.506452004 seconds time elapsed

After this commit:

         162.493654      task-clock (msec)         #    0.546 CPUs utilized
                 28      context-switches          #    0.172 K/sec
                  0      cpu-migrations            #    0.000 K/sec
              14567      page-faults               #    0.090 M/sec
          591784363      cycles                    #    3.642 GHz
    <not supported>      stalled-cycles-frontend
    <not supported>      stalled-cycles-backend
         1155878943      instructions              #    1.95  insns per cycle
          258056988      branches                  # 1588.105 M/sec
            1570485      branch-misses             #    0.61% of all branches

        0.297396523 seconds time elapsed
This function has been obsoleted by the previous commit. Remove it.
Use "static" functions where possible to give the compiler more
freedom for optimizations.
Revert the timer based redraw prevention, because we want to
take a new approach based on an idle worker.

This reverts commit 99a44dd.
A resize triggers an Expose event and we are going to handle changed
windows sizes there. So remove resize callback.
Add a function which will register a (Idle-) work procedure to do the
redraw when there are no more other events pending.

If the window size has changed after the last redraw, clear the
window to clean up wrongly scaled relicts.
Instead of doing a repaint on every Expose event, just trigger the work
procedure to do a repaint when the queue is idle.
Remove the now obsolete function.
@wwwutz
Copy link
Contributor

wwwutz commented Mar 22, 2019

fine, redraws like a boss. tested on zoophobie.

@wwwutz wwwutz merged commit c9b7779 into master Mar 22, 2019
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

delay redraw on huge input
2 participants