i''m running the following script: #pragma D option quiet profile:::tick-1sec / ++x >= 15 / { exit(0); } io:::start { @io_size[execname] = sum(args[0]->b_bcount); } on exit, the script prints out the value of @io_size, why? there''s no printa(), and i also specified "D option quiet" (i also tried -q). this seems to happen with any kind of probe: on exit(0) all the associative arrays defined in the script are being written on standard ouput. This message posted from opensolaris.org
alessioc wrote:> i''m running the following script: > > #pragma D option quiet > profile:::tick-1sec > / ++x >= 15 / > { > exit(0); > } > io:::start { > @io_size[execname] = sum(args[0]->b_bcount); > } > > on exit, the script prints out the value of @io_size, why? > there''s no printa(), and i also specified "D option quiet" (i also tried -q). > > this seems to happen with any kind of probe: on exit(0) all the associative arrays defined in the script are being written on standard ouput. > > > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.orgThe default action of an aggregation is to print it on exit if anything is in it. You might want to try adding the following: END { clear(@io_size); } alan. -- Alan Hargreaves - http://blogs.sun.com/tpenta Staff Engineer (Kernel/VOSJEC/Performance) Product Technical Support (APAC) Sun Microsystems I wentin the World''s Greatest shave for Leukaemia. See http://blogs.sun.com/tpenta
> The default action of an aggregation is to print it on exit if > anything is in it.what''s the rationale behind this behavior? shouldn''t the D option quiet turn off this verbosity too? or at least, shouldn''t be another pragma D option to change the default sction of aggregations on exit? i''m trying to parsing the stdout of some dtrace scripts searching for data given /explicitly/ to the stdoutput (eg. by using printa, printf, trace,..)... but as you say, dtrace produces stdoutput data even when there are no print* calls and even if the quiet mode is on. is this really good?
Alessio Cervellin wrote:>> The default action of an aggregation is to print it on exit if >> anything is in it. > > what''s the rationale behind this behavior?You''d need one of the iron chefs[1] to answer that one.> shouldn''t the D option quiet turn off this verbosity too?This one too.> or at least, shouldn''t be another pragma D option to change the default sction of aggregations on exit? > i''m trying to parsing the stdout of some dtrace scripts searching for data given /explicitly/ to the stdoutput (eg. by using printa, printf, trace,..)... but as you say, dtrace produces stdoutput data even when there are no print* calls and even if the quiet mode is on. is this really good? >I kind of like the idea of a pragma to consume uncleared aggregations on exit. What say you chefs? Shall I send you an RFE? alan. [1] The DTrace Iron Chefs - Mike, Bryan and Adam (an I guess one should also note the Iron Chef (Toolkit) - Brendan ;) ) -- Alan Hargreaves - http://blogs.sun.com/tpenta Staff Engineer (Kernel/VOSJEC/Performance) Product Technical Support (APAC) Sun Microsystems
On 5/12/06, Alan Hargreaves <Alan.Hargreaves at sun.com> wrote:> Alessio Cervellin wrote: > >> The default action of an aggregation is to print it on exit if > >> anything is in it. > > > > what''s the rationale behind this behavior? >am i missing something, the more interesting question is why save data if you aren''t going to use it?> You''d need one of the iron chefs[1] to answer that one. > > > shouldn''t the D option quiet turn off this verbosity too? >no this will just lead to bloat, in the version after that change took effect, people will want a #pragma not_that_quiet i still want to see my agregations....> This one too. > > > or at least, shouldn''t be another pragma D option to change the default sction of aggregations on exit?why not just have the user clear them if he wants it quiet, you can add it to a FAQ if you like, if it becomes one. But this is the first I heard of it. Adding a pragma for this seems broken the current design is sensible no need to change it. James Dickens uadmin.blogspot.com> > i''m trying to parsing the stdout of some dtrace scripts searching for data given /explicitly/ to the stdoutput (eg. by using printa, printf, trace,..)... but as you say, dtrace produces stdoutput data even when there are no print* calls and even if the quiet mode is on. is this really good? > > > > I kind of like the idea of a pragma to consume uncleared aggregations on > exit. > > What say you chefs? Shall I send you an RFE? > > alan. > > [1] The DTrace Iron Chefs - Mike, Bryan and Adam (an I guess one should > also note the Iron Chef (Toolkit) - Brendan ;) ) > -- > Alan Hargreaves - http://blogs.sun.com/tpenta > Staff Engineer (Kernel/VOSJEC/Performance) > Product Technical Support (APAC) > Sun Microsystems > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >
On Fri, May 12, 2006 at 05:39:53PM +1000, Alan Hargreaves wrote:> alessioc wrote: > >i''m running the following script: > > > >#pragma D option quiet > >profile:::tick-1sec > >/ ++x >= 15 / > >{ > > exit(0); > >} > >io:::start { > > @io_size[execname] = sum(args[0]->b_bcount); > >} > > > >on exit, the script prints out the value of @io_size, why? > >there''s no printa(), and i also specified "D option quiet" (i also tried > >-q). > > > >this seems to happen with any kind of probe: on exit(0) all the > >associative arrays defined in the script are being written on standard > >ouput. > > > > > >This message posted from opensolaris.org > >_______________________________________________ > >dtrace-discuss mailing list > >dtrace-discuss at opensolaris.org > > > The default action of an aggregation is to print it on exit if anything > is in it. > > You might want to try adding the following: > > END { clear(@io_size); }I think you mean trunc(@io_size); clear just zeros the values, leaving the keys alone. Cheers, - jonathan> alan. > -- > Alan Hargreaves - http://blogs.sun.com/tpenta > Staff Engineer (Kernel/VOSJEC/Performance) > Product Technical Support (APAC) > Sun Microsystems > > I wentin the World''s Greatest shave for Leukaemia. See > http://blogs.sun.com/tpenta > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Jonathan Adams, Solaris Kernel Development
> What say you chefs? Shall I send you an RFE?As James mentioned, it''s kind of strange to be collecting data if you don''t care about it. The default is to emit any un-printa()ed aggregations when the enabling exits, and it would a) be annoying to change the default for anyone relying on it and b) I''m not sure a compelling argument has been made for why that change _should_ be made. There are a couple of work arounds that have been mentioned, but the best advice is probably not to bother collecting data you don''t need. Adam On Fri, May 12, 2006 at 06:49:42PM +1000, Alan Hargreaves wrote:> Alessio Cervellin wrote: > >>The default action of an aggregation is to print it on exit if > >>anything is in it. > > > >what''s the rationale behind this behavior? > > You''d need one of the iron chefs[1] to answer that one. > > >shouldn''t the D option quiet turn off this verbosity too? > > This one too. > > >or at least, shouldn''t be another pragma D option to change the default > >sction of aggregations on exit? > >i''m trying to parsing the stdout of some dtrace scripts searching for data > >given /explicitly/ to the stdoutput (eg. by using printa, printf, > >trace,..)... but as you say, dtrace produces stdoutput data even when > >there are no print* calls and even if the quiet mode is on. is this really > >good? > > > > I kind of like the idea of a pragma to consume uncleared aggregations on > exit. > > What say you chefs? Shall I send you an RFE? > > alan. > > [1] The DTrace Iron Chefs - Mike, Bryan and Adam (an I guess one should > also note the Iron Chef (Toolkit) - Brendan ;) ) > -- > Alan Hargreaves - http://blogs.sun.com/tpenta > Staff Engineer (Kernel/VOSJEC/Performance) > Product Technical Support (APAC) > Sun Microsystems > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Solaris Kernel Development http://blogs.sun.com/ahl
On Fri, May 12, 2006 at 02:39:56PM -0700, Adam Leventhal wrote:> > What say you chefs? Shall I send you an RFE? > > As James mentioned, it''s kind of strange to be collecting data if you don''t > care about it. The default is to emit any un-printa()ed aggregations when > the enabling exits, and it would a) be annoying to change the default for > anyone relying on it and b) I''m not sure a compelling argument has been > made for why that change _should_ be made.Also, if you really have a bee up your butt about this, you can use freopen() with "/dev/null", and print the aggregation: END { freopen("/dev/null"); printa(@goaway); freopen(""); } (The last freopen() restores stdout to its previous value.) Note that you will have to enable destructive actions to use freopen()... - Bryan -------------------------------------------------------------------------- Bryan Cantrill, Solaris Kernel Development. http://blogs.sun.com/bmc
> Alessio Cervellin wrote: > >> The default action of an aggregation is to print it on exit if > >> anything is in it. > > > > what''s the rationale behind this behavior? > > You''d need one of the iron chefs[1] to answer that one.For the curious, the rationale was that it was very important to us to preserve the ability to write simple programs on the command-line very rapidly, while at the same time providing the ability to create more complex programs in an editor. So being able to say, e.g. dtrace -n syscall:::entry''{@[execname] = count()}'' or whatever and see your aggregation output without needing other stuff was important to us in terms of usability from the command-line. -Mike -- Mike Shapiro, Solaris Kernel Development. blogs.sun.com/mws/
James Dickens wrote:>> >> The default action of an aggregation is to print it on exit if >> >> anything is in it. >> > >> > what''s the rationale behind this behavior? >> > > am i missing something, the more interesting question is why save data > if you aren''t going to use it?i can''t think of a specific use case right now. i raised this issue just ''cause i accidentally discovered this behavior when i was debugging some scripts: i was commenting out some printa() calls on aggregations, though i was still getting their prints on the stdout... and i just thought it was quite weird!
Michael Shapiro wrote:> For the curious, the rationale was that it was very important to us to preserve > the ability to write simple programs on the command-line very rapidly, while at > the same time providing the ability to create more complex programs in an > editor. So being able to say, e.g. > > dtrace -n syscall:::entry''{@[execname] = count()}'' > > or whatever and see your aggregation output without needing other stuff > was important to us in terms of usability from the command-line.this is a very good rationale. now i wonder if there''s a good rationale to not include a pragma option to let users disable this behavior... as i wrote before, it could happen, at least for debugging purproses, to not print out some aggregations (just by removing their printa() and not by removing their declarations at all or by adding any longer workaround). think about a 1.000 lines dtrace script with hundred of aggregations...