[fpc-devel] Messages overhead

Sergei Gorelkin sergei_gorelkin at mail.ru
Thu Jul 15 18:36:08 CEST 2010


Tomas Hajny пишет:
> On Thu, July 15, 2010 14:06, Graeme Geldenhuys wrote:
>> Op 2010-07-15 06:26, Sergei Gorelkin het geskryf:
>>> Message processing indeed includes some overhead, but this is not #1
>>> bottleneck to worry about.
>>> Maybe #10 or so.
>> Well, any optimization is better than none. Irrespective of where you rank
>> it, one has to start somewhere.
> 
> Have I misunderstood something, or is this optimization really just about
> the fact that message loading is not necessary if the compiler is
> requested to output no messages at all? Even if this (probably extremely
> rare!) case happens, the difference must be completely negligible unless
> you perform very many compilations of simple and short source files
> without further dependencies (which doesn't sound like a typical use case
> to me ;-) ), right?
> 
The issue was that, whenever compiler needs to output a message, it:
- loads a messagefile (once in a session)
- looks up the message by number
- performs the parameter substitution (this involves AnsiStrings, so is somewhat heavy)
- only then checks if it should really print the resulting string.

The most amount of messages come from unit search; the system units are loaded every time, so you 
always have about several thousands messages loaded and discarded. This was taking a noticeable 
amount of executed CPU instructions (profiled with Valgrind).
With the patch applied in r9297, I was able to cut the total number of executed instructions down by 
20%, but that gave no increase in perceived speed of compilation. So I decided not to put much more 
effort to this issue.

Although, modifying the messaging system in a way when CheckVerbosity() is called as soon as 
possible (before parameter substitution and other processing) could be beneficial.

Regards,
Sergei



More information about the fpc-devel mailing list