[Qt-creator] Clang Code Model Questions

Mike Jackson imikejackson at gmail.com
Sun Nov 22 17:41:26 CET 2015

> On Nov 18, 2015, at 4:14 PM, Cristian Adam <cristian.adam at gmail.com> wrote:
> On 11/18/2015 6:10 PM, Mike Jackson wrote:
>> The wait cursor does not appear when looking at the QtCreator code base at the file you specified. I could still type cppModelManager before the completion list would pop up for “cppModelManager”. Typing a “->” after that was about a 0.5 second delay for the completion list to pop up. I strung together a few more completions and they were relatively “fast” (around a second to get the completion list). never saw the spinning beach ball with any of that.
>> In our codes we are including boost in a few spots and if I had to guess the templates might be what is holding up the clang back end? Otherwise our code bases are similar on a total files and current document basis.
>> Thoughts?20 1
>> Mike Jackson
> Try Lyx <http://www.lyx.org/> from their git repository. Lyx uses Boost, Qt5 and more.
> My CMake configure parameters were:
> Global/Indexing Snapshot : 2558 Documents
> Current Editor's Snapshot (Text3.cpp) : 785 Documents.
> Went to the last method in Text3.cpp – Text::inDescriptionItem and added a "this->". Took like ~6 seconds to
> get the popup (older i7 2.6GHz CPU). During the ~6 seconds I didn't see any Windows wait cursor.
> On Qt Creator master on every "this->" I get like ~6 seconds.
> With Qt Creator 3.5.1 the first time is slow the next times are way faster, like one second.
> This is a regression and I've opened up QTCREATORBUG-15365 <https://bugreports.qt.io/browse/QTCREATORBUG-15365>
> Cheers,
> Cristian.

Just to follow up on this some more. After downloading the nightly from Nov.  20, 2015 and switching to the QtCreator Code model (after reading some commit messages) I am happy to report MUCH better code completion times. We moved from constant spinning beach balls in OS X to “fairly fast, still a bit slow” code completions.

The next thing we did was move from boost::shared_ptr to std::shared_ptr (since we were slowly moving our codes to C++11 anyways) and remove all instances of boost::shared_array and instead use other types of shared  arrays (std::vector in most cases).

On one of our test files we dropped from 705 documents in the current editors code model to around 450. Then we ran “include what you use” on that same file and follow some of its output and refactored some of our includes which reduced the number of documents to around 350.

Now with the QtCreator code model we get near instant code completion for those files that we updated. Unfortunately the Clang Code model still beach balls way too much or simply will not offer any type of completion. When it does give a completion, or syntax color the source codes, it does work well.

My take away is the following:
* While the clang code model may be “better” (subjective) it is still young and not quite as optimized as QtCreator’s code model
* Both code model's will have scaling issues when there is a “large” number of files that go into creating the model for the current editor, especially if those sources are highly templated codes.
* Carefully review your OWN code to see if you are including more files that you really need. Tools like “include what you use” were invaluable to us when trying to figure out which #include directives could be moved to into the .cpp files or outright removed. “Include What You Use” can be wrong in some instances so its output should not be taken verbatim but is still valuable.

Mike Jackson

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20151122/6070affd/attachment.html>

More information about the Qt-creator mailing list