This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcov: option to instrument whole basic block graph, no use of spanning tree optimization

Holger Blasum <> writes:

> Rationale: gcov is not robust in a threaded environment, the patch
>     makes it more robust.
> In particular, in threaded environments on can observe two effects: 
> (1) underreporting when coverage counters are overwritten by another 
> instance of a thread after a thread switch. 
> (2) generation of arbitrary (even negative) values by subtraction when 
> reconstructing the whole tree from the used by the spanning tree 
> optimization mechanism. (Recall that subtraction is messy numerically.) 
> With the current gcov framework (I think) one cannot do anything 
> really generic about (1). 

A better fix would be to make all the gcov data per thread data.

This is supported on most modern OS in a straight forward way
with a storage class modifier. This would fix all the races and give 
always accurate information.

Another advantage of this is that it would speed data collection
with multiple threads -- no frequent cache line bouncing on the
counters when multiple CPUs modify them in parallel.

The only change needed would be to sum it up explicitely on
thread destruction into a global copy that is accessed atomically.


-- -- Speaking for myself only.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]