I''ve run into this from time to time.
Simple example;
#dtrace -n ''hotspot27563::: { @[probename]=count(); } tick-1sec {
printa(@); clear(@); }''
The sample output (below) shows a couple functions (probename)
with a value of zero. By virtue of the fact that it appears in the
aggregation at all implies that minimal value should be 1 (I would think).
(FYI - this is on OSOL 2009.06, x86 system).
Thanks,
/jim
gc-begin 0
gc-end 0
mem-pool-gc-begin 0
mem-pool-gc-end 0
thread-start 3
thread-stop 3
gc-begin 0
gc-end 0
mem-pool-gc-begin 0
mem-pool-gc-end 0
thread-start 4
thread-stop 4
On Tue, Oct 27, 2009 at 02:00:52PM -0400, Jim Mauro wrote:> I''ve run into this from time to time. > > Simple example; > > #dtrace -n ''hotspot27563::: { @[probename]=count(); } tick-1sec { > printa(@); clear(@); }'' > > The sample output (below) shows a couple functions (probename) > with a value of zero. By virtue of the fact that it appears in the > aggregation at all implies that minimal value should be 1 (I would think).Clear clears all values in the aggregation to 0; to remove all elements from the aggregation, you want trunc(@a). (clear() can be useful if you want a running list of everything seen, but count only for the most recent hits) Cheers, - jonathan> (FYI - this is on OSOL 2009.06, x86 system). > > Thanks, > /jim > > > gc-begin 0 > gc-end 0 > mem-pool-gc-begin 0 > mem-pool-gc-end 0 > thread-start 3 > thread-stop 3 > > gc-begin 0 > gc-end 0 > mem-pool-gc-begin 0 > mem-pool-gc-end 0 > thread-start 4 > thread-stop 4 > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
On Oct 27, 2009, at 6:03 PM, Jonathan Adams wrote:> Clear clears all values in the aggregation to 0; to remove all > elements from > the aggregation, you want trunc(@a).That''s what I wanted to say but doesn''t printa(@a) come before the clear? --- firefox for android! http://wagerlabs.com
D''oh! Thanks Jonathan Adams wrote:> On Tue, Oct 27, 2009 at 02:00:52PM -0400, Jim Mauro wrote: > >> I''ve run into this from time to time. >> >> Simple example; >> >> #dtrace -n ''hotspot27563::: { @[probename]=count(); } tick-1sec { >> printa(@); clear(@); }'' >> >> The sample output (below) shows a couple functions (probename) >> with a value of zero. By virtue of the fact that it appears in the >> aggregation at all implies that minimal value should be 1 (I would think). >> > > Clear clears all values in the aggregation to 0; to remove all elements from > the aggregation, you want trunc(@a). > > (clear() can be useful if you want a running list of everything seen, but > count only for the most recent hits) > > Cheers, > - jonathan > > >> (FYI - this is on OSOL 2009.06, x86 system). >> >> Thanks, >> /jim >> >> >> gc-begin 0 >> gc-end 0 >> mem-pool-gc-begin 0 >> mem-pool-gc-end 0 >> thread-start 3 >> thread-stop 3 >> >> gc-begin 0 >> gc-end 0 >> mem-pool-gc-begin 0 >> mem-pool-gc-end 0 >> thread-start 4 >> thread-stop 4 >> >> _______________________________________________ >> dtrace-discuss mailing list >> dtrace-discuss at opensolaris.org >>
On Tue, Oct 27, 2009 at 06:06:44PM +0000, Joel Reymont wrote:> > On Oct 27, 2009, at 6:03 PM, Jonathan Adams wrote: > > >Clear clears all values in the aggregation to 0; to remove all > >elements from > >the aggregation, you want trunc(@a). > > That''s what I wanted to say but doesn''t printa(@a) come before the > clear?Your original script, as a #! script: --- cut here --- #!/usr/sbin/dtrace -s hotspot27563::: { /* every time a probe is hit, record it in the aggregation under name */ @[probename]=count(); } profile:::tick-1sec { printa(@); /* print the current contents of @ */ clear(@); /* clear the counts in @ to 0 */ } --- cut here --- Without the clear(), you would just print the running counts every second. With the clear(), you print the running counts, then clear them to zero *without removing the aggregation entries*. With s/clear/trunc/g, you would *remove all aggregation entries* from @. Since I don''t have a java process handy, I''ll demonstrate using the proc::: provider: % dtrace -n''proc:::{@[probename]=count()}'' -n''tick-1s{printa(@);}'' dtrace: description ''proc:::'' matched 15 probes dtrace: description ''tick-1s'' matched 1 probe CPU ID FUNCTION:NAME 0 66088 :tick-1s signal-send 30 signal-handle 31 ... 0 66088 :tick-1s signal-handle 97 signal-send 131 0 66088 :tick-1s exit 2 lwp-exit 2 create 3 lwp-create 3 lwp-start 3 signal-discard 3 start 3 exec 4 exec-success 4 signal-handle 121 signal-send 162 0 66088 :tick-1s signal-discard 5 exit 10 lwp-exit 10 create 11 exec 11 exec-success 11 lwp-create 11 lwp-start 11 start 11 signal-handle 158 signal-send 203 0 66088 :tick-1s signal-discard 5 exit 10 lwp-exit 10 exec-success 11 create 13 exec 13 lwp-create 13 lwp-start 13 start 13 signal-handle 176 signal-send 252 ... 0 66088 :tick-1s signal-discard 5 exec 18 exec-success 18 exit 18 lwp-exit 18 create 19 lwp-create 19 lwp-start 19 start 19 signal-handle 299 signal-send 399 ^C With clear(), this would look like: % dtrace -n''proc:::{@[probename]=count()}'' -n''tick-1s{printa(@);clear(@)}'' dtrace: description ''proc:::'' matched 15 probes dtrace: description ''tick-1s'' matched 1 probe CPU ID FUNCTION:NAME 0 66088 :tick-1s signal-send 30 signal-handle 31 ... 0 66088 :tick-1s signal-handle 67 signal-send 100 0 66088 :tick-1s exit 2 lwp-exit 2 create 3 lwp-create 3 lwp-start 3 signal-discard 3 start 3 exec 4 exec-success 4 signal-handle 24 signal-send 31 0 66088 :tick-1s exit 2 signal-discard 2 exec 7 exec-success 7 create 8 lwp-create 8 lwp-exit 8 lwp-start 8 start 8 signal-handle 37 signal-send 41 0 66088 :tick-1s signal-discard 0 exit 0 lwp-exit 0 exec-success 0 create 2 exec 2 lwp-create 2 lwp-start 2 start 2 signal-handle 18 signal-send 49 ... 0 66088 :tick-1s signal-discard 0 exec 0 exec-success 0 exit 0 lwp-exit 0 create 0 lwp-create 0 lwp-start 0 start 0 signal-handle 5 signal-send 6 ^C With trunc(), this looks like: % dtrace -n''proc:::{@[probename]=count()}'' -n''tick-1s{printa(@);trunc(@)}'' dtrace: description ''proc:::'' matched 15 probes dtrace: description ''tick-1s'' matched 1 probe CPU ID FUNCTION:NAME 0 66088 :tick-1s signal-send 30 signal-handle 31 ... 0 66088 :tick-1s signal-handle 67 signal-send 100 0 66088 :tick-1s exit 2 lwp-exit 2 create 3 lwp-create 3 lwp-start 3 signal-discard 3 start 3 exec 4 exec-success 4 signal-handle 24 signal-send 31 0 66088 :tick-1s exit 2 signal-discard 2 exec 7 exec-success 7 create 8 lwp-create 8 lwp-exit 8 lwp-start 8 start 8 signal-handle 37 signal-send 41 0 66088 :tick-1s create 2 exec 2 lwp-create 2 lwp-start 2 start 2 signal-handle 18 signal-send 49 ... 0 66088 :tick-1s signal-handle 5 signal-send 6 ^C Is that clear? Cheers, - jonathan> > --- > firefox for android! > http://wagerlabs.com