Revision 64746da...

Go back to digest for 21st October 2012

Optimization in Development Tools

Milian Wolff committed changes in [kdevplatform] /:

Greatly reduce memory consumption by using IndexedString in the BackgroundParser.

IndexedString::str or ::toUrl do not leverage implicit sharing (see recently
added unit test that shows that). Thus we end up duplicating the URLs in-memory
when we add all project files to the BackgroundParser.

Instead, we now leverage IndexedString which greatly reduces the memory consumption.
In my test with two big projects (QtWebKit and QtBase from Qt 5) I see a drop
of from about 815MB RSS down to about 550MB RSS.

Furthermore this new API is also faster as we can safe quite a few conversions
between KUrl and IndexedString. And the hasing of an IndexedString is also faster
compared to a KUrl. The TestBackgroundparser::benchmark shows a speed increase
of about 10%, i.e. ~1.9s vs ~2.1s.

NOTE: This commit breaks the API/ABI and is not source compatible. When you port
your code to this new API, I encourage you to review the callers. Most often
you do not want to use KUrl anyways but an IndexedString.

NOTE2: While writing this patch, I found a few more places where we could and should
change our API to use IndexedString instead of KUrl to decrease the number of

File Changes

Modified 12 files
  •   shell/projectcontroller.cpp
  •   language/backgroundparser/backgroundparser.cpp
  •   language/backgroundparser/backgroundparser.h
  •   language/backgroundparser/documentchangetracker.cpp
  •   language/backgroundparser/parseprojectjob.cpp
  •   language/backgroundparser/parseprojectjob.h
  •   language/codegen/documentchangeset.cpp
  •   language/duchain/duchain.cpp
  •   language/duchain/duchainutils.h
  •   language/backgroundparser/tests/test_backgroundparser.cpp
  •   language/backgroundparser/tests/test_backgroundparser.h
  •   shell/kross/xmltokross/duchainextractor.cpp
12 files changed in total