On Memory consumption of KDevelop-PG

Alexander Dymo alexander.dymo at gmail.com
Fri Jan 8 23:53:01 UTC 2010


> There is a few things we can do in future that would have a huge impact:
> - Replace size_t with uint everywhere within the parser
> - Move the "AST* parent" and "DUContext* ducontext" members out of the AST,
> into a separate map in ParseSession, as they are not needed in most cases.
> - Do the same thing with the "comments" member of CommentAST

I've tried to replace size_t with uint and remove AST*parent pointer. Here are 
the results:

== my test file ==
						heap total	heap peak
original:					506			399
with uint instead of size_t	459			351
without parent pointer		481			372

== kdevplatform ==
						heap total	heap peak
original:					7826		193
with uint instead of size_t	7640		193
without parent pointer		7790		193


Conclusions:
for my large C/C++ file we save:
size_t => uint: 			50M
removing parent pointer:	20M

Total 70M which is not bad - only 330M will be used during the parsing for 
that file.

For kdevplatform the peak memory consumption isn't changed because AST's are 
usually small and they are deleted when file is parsed. But these changes can 
save us some malloc/realloc calls. If you look at heap total, you'll see that 
we allocate 186M less after changing to uints and 36M less after removing 
parent pointer.
Total, we can allocate 222M less.

So, these optimizations wouldn't hurt at all. Shall I proceed and post patches 
for review?




More information about the KDevelop-devel mailing list