[PATCH] Reduce GC overhead of the C++ lexer buffer

Mark Mitchell mark@codesourcery.com
Mon Jun 19 17:25:00 GMT 2006


Richard Guenther wrote:
> At the moment we have
> 
> cp/parser.c:292 (cp_lexer_new_main)  0: 0.0%  82369152:33.3%  0: 0.0% 
> 15784576:37.2%  7
> 
> which is due to the fact that the initial lexer buffer size is no where
> near a power-of-two value and we keep gc-reallocating the vector, doubling
> its size.
> 
> With the following patch, this overhead is removed nearly completely
> 
> cp/parser.c:266 (cp_lexer_new_main)                       0: 0.0%         
> 36: 0.0%          0: 0.0%          4: 0.0%          1
> 
> Comments?

This is a good result -- but what test case did you use?  Also, can you
explain why it's important to use a power of two here?  Is it because
that avoids having to copy data to new kernel pages, or something?

> ! #define CP_LEXER_BUFFER_SIZE (262144/sizeof(cp_token))

Please right as "256 * 1024" rather than as 262144 to make it obvious
that this is a power-of-two; not everyone knows there powers up that
high.  Also, why not just right 8 * 1024?  Why does it make sense to use
256K/sizeof?

I will approve the patch, once I understand a little better.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Gcc-patches mailing list