Review Request: Patch to reduce C++ memory consumption by removing DuContext* pointer from the AST

Milian Wolff mail at milianw.de
Tue May 4 21:02:02 UTC 2010


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard.kde.org/r/2938/#review5407
-----------------------------------------------------------


shall we close this as discarded adymo?

- Milian


On 2010-02-15 11:48:01, Alexander Dymo wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviewboard.kde.org/r/2938/
> -----------------------------------------------------------
> 
> (Updated 2010-02-15 11:48:01)
> 
> 
> Review request for KDevelop.
> 
> 
> Summary
> -------
> 
> C++ parser's AST base class has "KDevelop::DUContext* ducontext" pointer which isn't used for most of the nodes. For example, the primary expression AST nodes do not open a new context and if your file is big, the memory is wasted.
> 
> This patch removes the context pointer from AST and instead fills a QMap<AST*, DuContext*> in the ParseSession class.
> 
> For me and my huge files this saves ~50M of memory.
> 
> Note, that the map will be ~2% slower than the pointer (when building uses for example). Performance testing results are below.
> 
> 
> Diffs
> -----
> 
>   /trunk/extragear/sdk/kdevelop/languages/cpp/cppduchain/contextbuilder.cpp 1090158 
>   /trunk/extragear/sdk/kdevelop/languages/cpp/cppduchain/declarationbuilder.cpp 1090158 
>   /trunk/extragear/sdk/kdevelop/languages/cpp/cppduchain/expressionparser.cpp 1090158 
>   /trunk/extragear/sdk/kdevelop/languages/cpp/cppduchain/expressionvisitor.cpp 1090158 
>   /trunk/extragear/sdk/kdevelop/languages/cpp/cppduchain/name_visitor.cpp 1090158 
>   /trunk/extragear/sdk/kdevelop/languages/cpp/cppduchain/typebuilder.cpp 1090158 
>   /trunk/extragear/sdk/kdevelop/languages/cpp/cppduchain/usebuilder.cpp 1090158 
>   /trunk/extragear/sdk/kdevelop/languages/cpp/parser/ast.h 1090158 
>   /trunk/extragear/sdk/kdevelop/languages/cpp/parser/parsesession.h 1090158 
>   /trunk/extragear/sdk/kdevelop/languages/cpp/parser/parsesession.cpp 1090158 
> 
> Diff: http://reviewboard.kde.org/r/2938/diff
> 
> 
> Testing
> -------
> 
> All tests pass.
> 
> Optimization results: my test files:
> before: 703M
> after: 655M
> 48M saved
> 
> 
> Performance testing:
> 
> kdevplatform:	peak memory	duchainify: visible-declarations	du: all-declarations-and-uses
> before:		150M		52					79.35
> after:		150M		52					81
> 
> kdevelop:	peak memory	duchainify: visible-declarations	du: all-declarations-and-uses
> before:		98M		22.86					41.77
> after:		98M		22.85					42.55
> 
> Performance regression for use-building is 2% due to this patch.
> For KDevelop and KDevplatform projects where there are no huge files, this patch doesn't save any memory.
> 
> 
> Thanks,
> 
> Alexander
> 
>





More information about the KDevelop-devel mailing list