Summary: | Background parser slows down the GUI thread for large projects | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | Wei-Cheng Pan <legnaleurc> |
Component: | Language Support: CPP (Clang-based) | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | kilo |
Priority: | NOR | ||
Version: | 5.0.1 | ||
Target Milestone: | --- | ||
Platform: | Debian unstable | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/kdevplatform/77e98b914694ae144fbf4c319b157b1750f729f7 | Version Fixed In: | 5.0.3 |
Attachments: |
perf result after it start parsing C++ files
perf result after it start parsing C++ files another hotspot |
Description
Wei-Cheng Pan
2016-09-26 09:39:10 UTC
The short living threads are used by libclang for crash resilience. You can verify whether that really is the problem by temporarily disabling that feature. For that, you will need to recompile KDevelop though, and add a call to `clang_toggleCrashRecovery(false)`, e.g. in `kdevelop/language/clang/duchain/clangindex.cpp`, before the call to `clang_CXIndex_setGlobalOptions`. That said, I doubt that this is the reason for the high CPU usage. Could you please use a profiler to get some hard data? - install debug symbols for kdevelop + kdevplatform - profile CPU with perf: perf record --call-graph dwarf --pid $(pidof kdevelop) # wait a couple of seconds while kdevelop has high CPU usage # ^C -> this stops the record and writes a `perf.data` file then run perf report --no-children -g graph | bzip2 > perf.report.bz2 and upload the report here. Created attachment 101341 [details]
perf result after it start parsing C++ files
Created attachment 101612 [details]
perf result after it start parsing C++ files
Sorry, I think ther previous perf result is not right, here is the correct one (I think).
Looks like the progress events are flooding the GUI thread.
I commented out this line: m_parser->updateProgressBar(); in KDevelop::BackgroundParserPrivate::parseDocumentsInternal and the GUI thread becomes idle and works normally. Maybe we can decrease the update frequency for large project? I have tried commenting out that line. Honestly I don't miss anything in the progress bar (It still updates just fine). Another benefit seams to be, that we are loosing a lot of unnecessary synchronization points for the parser threat. At least kdevelop now uses all my cores when parsing, while it previously didn't. Is there any good reason to keep this line? Created attachment 101637 [details]
another hotspot
This report was measured after I commented out the line I mentioned before.
Looks like there is another function keeps update the progress bar. Not as busy as the one in background parser though.
It's KDevelop::BackgroundParser::parseComplete emitting the signal. We'll need to add a timer to update the progress bar, instead of notify the main thread in every single step. @Wei-Cheng: Want to get started hacking on KDevelop? Looks like you're almost there. :) Patches welcome! See https://www.kdevelop.org/contribute-kdevelop Git commit 77e98b914694ae144fbf4c319b157b1750f729f7 by Kevin Funk, on behalf of Wei-Cheng Pan. Committed on 16/11/2016 at 23:58. Pushed by kfunk into branch '5.0'. Periodically update progress bar Summary: To avoid progress bar event flooding, adds a long-term timer to send the events periodically FIXED-IN: 5.0.3 Reviewers: #kdevelop, kfunk Subscribers: brauch, kfunk, kdevelop-devel Differential Revision: https://phabricator.kde.org/D3110 M +24 -6 language/backgroundparser/backgroundparser.cpp M +2 -1 language/backgroundparser/backgroundparser.h http://commits.kde.org/kdevplatform/77e98b914694ae144fbf4c319b157b1750f729f7 |