Cache ProblemPointers per translation unit

Authored by mwolff on Jan 9 2018, 6:56 PM.



For visibility purposes, all 'inclue file not found' errors are
associated with all files in a TU, since these usually completely
break the interpretation of a file. But in some situations, this
triggers a severe performance degradation:

When the TU has a deep include stack depth and a file is not found
somewhere at the bottom of the stack, then it will have one child
diagnostic for every "included from ..." file higher up in the stack.
Now if we would repeatedly build and intern the KDevelop::Problem
representation for these diagnostics, for every file in the TU, we
sometimes ended up spending *minutes* to create all the problems
in ParseSession::problemsForFile!

To workaround this situation, cache the ProblemPointer in the
ParseSessionData for a given translation unit. This way, we will
only convert a given diagnostic and its child diagnostics once per TU
instead of once per file contained in a TU.

In my case this brings down the time spent in problemsForFile for a
single TU from ~7min (sic!) down to ~12s. While the latter is still
a lot, this is already much more bearable.

BUG: 386720

Diff Detail

R32 KDevelop
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
mwolff created this revision.Jan 9 2018, 6:56 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptJan 9 2018, 6:56 PM
mwolff requested review of this revision.Jan 9 2018, 6:56 PM
kfunk accepted this revision.Jan 10 2018, 10:27 AM
kfunk added a subscriber: kfunk.


To 5.2 branch please.


m_diagnostics -> m_diagnosticsCache for readability?

This revision is now accepted and ready to land.Jan 10 2018, 10:27 AM
This revision was automatically updated to reflect the committed changes.