Revision 750765
Go back to digest for 23rd December 2007Optimization in Development Tools
Profiling has shown that DocumentRange was one of the biggest remaining memory-hogs, especially on 64-bit systems KTextEditor::Range takes much more memory than the actual content because the data is split across multiple separately allocated blocks.
Also, it is inefficient to copy around, and DocumentRanges maintain a hierarchy that isn't needed at all, but also takes a lot of memory.
Solution:
Create efficient self-contained classes SimpleRange and SimpleCursor, that are used for each duchain object. Stop using DocumentRange in DocumentRangeObject. Instead, now each duchain object has one permanently stored SimpleRange, and a SmartRange pointer that is only nonzero when the document is loaded and has a smart-range.
The SimpleRange and the SmartRange are synchronized on access.
Result:
- No more thread-unsafe range access in DocumentRangeObject::textRange()
- Significantly less memory consumption
- More efficient serializability because the SimpleRange is embedded in the shared d-pointer.
By the way the duchain initializations were cleaned up a little, and some yet unnoticed bugs there fixed.
File Changes
- /trunk/KDE/kdevplatform/editor
- /simplecursor.h
- /simplerange.h
- /trunk/KDE/kdevplatform
- /editor/CMakeLists.txt
- /editor/documentrangeobject.cpp
- /editor/documentrangeobject.h
- /editor/documentrangeobject_p.h
- /editor/editorintegrator.cpp
- /editor/editorintegrator.h
- /editor/editorintegratorstatic.cpp
- /editor/editorintegratorstatic.h
- /language/CMakeLists.txt
- /language/duchain/classfunctiondeclaration.cpp
- /language/duchain/classfunctiondeclaration.h
- /language/duchain/classmemberdeclaration.cpp
- /language/duchain/classmemberdeclaration.h
- /language/duchain/classmemberdeclaration_p.h
- /language/duchain/contextowner_p.h
- /language/duchain/declaration.cpp
- /language/duchain/declaration.h
- /language/duchain/declaration_p.h
- /language/duchain/definition.cpp
- /language/duchain/definition.h
- /language/duchain/definition_p.h
- /language/duchain/duchain.cpp
- /language/duchain/duchainbase.cpp
- /language/duchain/duchainbase.h
- /language/duchain/duchainbase_p.h
- /language/duchain/ducontext.cpp
- /language/duchain/ducontext.h
- /language/duchain/ducontext_p.h
- /language/duchain/dumpdotgraph.cpp
- /language/duchain/forwarddeclaration.cpp
- /language/duchain/forwarddeclaration.h
- /language/duchain/functiondeclaration.cpp
- /language/duchain/functiondeclaration.h
- /language/duchain/identifiedtype.cpp
- /language/duchain/namespacealiasdeclaration.cpp
- /language/duchain/namespacealiasdeclaration.h
- /language/duchain/smartconverter.cpp
- /language/duchain/topducontext.cpp
- /language/duchain/topducontext.h
- /language/duchain/use.cpp
- /language/duchain/use.h
- /language/duchain/use_p.h
- /plugins/classbrowser/classtree.cpp
- /plugins/duchainviewer/duchainmodel.cpp
- /plugins/duchainviewer/duchainmodel.h
- /plugins/duchainviewer/duchaintree.cpp
- /plugins/quickopen/projectitemquickopen.cpp
- /plugins/usehighlight/usehighlight.cpp