Skip to content

problemreporter: optimize resizing columns

ProblemTreeView::resizeColumns() is invoked several times whenever the active document changes, even if Problems tool view is not visible. When there are 10 problems or more, at least two of these invocations run longer than a millisecond. The specific running times of a single call to resizeColumns() on my system are listed in the following table:

    Number of problems  time spent in resizeColumns() in milliseconds

                  15      3
                 100     20
                 650    120
                4500    200

At this commit each call to resizeColumns() takes up to 0.02 ms. Since the column widths no longer depend on detected problems, this function is now called only when Problems tool view is resized, not each time a new problem appears or an existing problem is fixed.

The advantages of ideal column widths are not important enough to justify possibly significant slowdown of KDevelop. For one thing, most users don't use Problems tool view very often. Also the optimum column widths can turn out unreasonably large if a problem description or a file path is overly long. And frequent column width changes can be distracting and thus counterproductive. When the user is looking at a problem list and wants to see complete problem descriptions, double clicking on a column separator in the tree view's header resizes the preceding column to contents. An occasional double click shouldn't be a big burden.

This column-resizing performance trap was introduced in 8c066b68. Before that commit optimum column widths were recomputed only in case of fewer than 15 problems.

Just early-returning from ProblemTreeView::resizeColumns() when the tree view is hidden is not good enough, because activating a document changes active part, invokes KParts::MainWindow::createGUI() and so reconstructs KDevelop UI, which unnoticeably briefly shows (previously visible) Problems tool view and thus bypasses the early return.

This optimization was first implemented in !132 (closed) The earlier merge request was closed because the resizing was substantially sped up by setting uniform row heights to true. But the resizing still has unreasonably high impact on KDevelop performance. This commit differs from the merge request in the following ways:

  1. ProblemTreeView::resizeColumns() is called only when needed, that is, when heuristic column widths change, not when the problem list changes.
  2. Heuristic resizing happens less often, so when the user resizes some columns manually, KDevelop doesn't revert the changes so eagerly.
  3. Computations that do not depend on runtime parameters are performed at compile time (static constexpr).
  4. Minimum width in characters for 3 columns - Source, Line and Column - is reduced by 5. The reduced widths are still too large for all possible English column headers and contents. If in some other localization a header or Source text doesn't fit entirely, that shouldn't be a problem, because the user can easily resize columns once or twice to read these few strings.

Merge request reports