[dtrace-discuss] What am I missing in the dtrace script?

Peter Lawrence Peter.Lawrence at Sun.COM
Mon Jul 16 12:40:11 PDT 2007


Bart Smaalders wrote On 07/13/07 09:46 AM,:
> Brian D. Horn wrote:
> 
>>Wee Yeh Tan wrote:
>>
>>>On 7/13/07, Brian D. Horn <Brian.Horn at sun.com> wrote:
>>>
>>>>Ok, then the question becomes "Where is documented that aggregates are
>>>>MP safe, but scalars are
>>>>not MP safe?"
>>>
>>>Hah... I sort of saw that coming.  I recall seeing this somewhere
>>>though I cannot remember exactly where.  Didn't see it in Bryan's
>>>DTrace gotchas.
>>>
>>>Does this warrant a bug against the documentation?  Perhaps a note in
>>>the variables section saying that "Global variables are not MP safe."?
>>>
>>
>>I don't know whether it is a bug or not yet.  I may have missed some
>>piece of documentation or seen old documentation.  It also begs the
>>question of "Why was it decided that scalars should not be MP safe?"
>>(assuming that is was decided as such!).
> 
> 
> The question here isn't whether "scalaers are mt-safe", it's whether
> or not the ++ and -- operators are atomic.
> 
> Would you expect
> 
> foo = foo + 1;
> 
> to work safely?
> 
> How about:
> 
> bar = foo;
> 
> foo = bar + 1;
> 
> There's no implicit locking in DTrace.  Aggregations are specifically
> designed to be safe, and are documented as such:



Isn't it also true that there is no explicit locking available in DTrace,
therefore isn't the user lulled into believeing that this is all taken
care of automatically by DTrace.  I'm not saying it should, only that
the absense of locking needs to be more explicit. The fact that aggregates
are definately documented to be MP-safe doesn't relieve us from documenting
what happens in other circumstances.

-Pete.






> 
> 
>>For performance-related questions, aggregated data is often more 
> 
>  > useful than individual data points. DTrace provides several built-in
> 
>>aggregating functions. When an aggregating function is applied to 
>>subsets of a collection of data, then applied again to the results 
>>of the analysis of those subsets, the results are identical to the 
>>results returned by the aggregating function when it is applied to 
>>the collection as a whole.
>>
>>The DTrace facility stores a running count of data items for 
>>aggregations. The aggregating functions store only the current 
>>intermediate result and the new element that the function is being 
>>applied to. The intermediate results are allocated on a per-CPU basis.
>>Because this allocation scheme does not require locks, the implementation 
>>is inherently scalable.
> 
> 
> 
> 



More information about the dtrace-discuss mailing list