Robert Milkowski
2005-Dec-22 11:13 UTC
[dtrace-discuss] truncating aggregation output only
Hello dtrace-discuss, Sometimes I want to run a script for some time and every n second output N top entries. trunc() isn''t suitable here as it also removed keys/values. I want it ''coz over time if I use sum() entries which are normally truncated can actually get to top over a time. Maybe printa() extension, something like: printa(@b[10]) - to output top 10? -- Best regards, Robert mailto:rmilkowski at task.gda.pl
Robert Milkowski wrote:> Hello dtrace-discuss, > > Sometimes I want to run a script for some time and every n second > output N top entries. trunc() isn''t suitable here as it also removed > keys/values. I want it ''coz over time if I use sum() entries which > are normally truncated can actually get to top over a time. > > Maybe printa() extension, something like: printa(@b[10]) - to output > top 10? >Robert, that''s a really good idea. I worry about changing the syntax and overloading [] though. Perhaps a better idea would be to go the same way that we are doing column sorting? Bryan? alan. -- Alan Hargreaves - http://blogs.sun.com/tpenta Staff Engineer (Kernel/VOSJEC/Performance) Product Technical Support (APAC) Sun Microsystems
On Fri, Dec 23, 2005 at 09:11:54AM +1100, Alan Hargreaves wrote:> Robert Milkowski wrote: > >Hello dtrace-discuss, > > > > Sometimes I want to run a script for some time and every n second > > output N top entries. trunc() isn''t suitable here as it also removed > > keys/values. I want it ''coz over time if I use sum() entries which > > are normally truncated can actually get to top over a time. > > > > Maybe printa() extension, something like: printa(@b[10]) - to output > > top 10? > > > > Robert, that''s a really good idea. > > I worry about changing the syntax and overloading [] though. Perhaps a > better idea would be to go the same way that we are doing column > sorting? Bryan?Yeah, the way to do this would be via a new option. Something like "aggtop" or something? So your code would look like this: ... setopt("aggtop", "10"); printf("The top 10:\n"); printa(@); setopt("aggtop", "false"); /* or something... */ printf("\nThe whole lot:\n"); printa(@); (This would also allow you to, e.g., see the bottom ten by setting both "aggsortrev" and "aggtop".) How does that sit? - Bryan -------------------------------------------------------------------------- Bryan Cantrill, Solaris Kernel Development. http://blogs.sun.com/bmc
}Yeah, the way to do this would be via a new option. Something like }"aggtop" or something? So your code would look like this: } } ... } } setopt("aggtop", "10"); } printf("The top 10:\n"); } printa(@); } } setopt("aggtop", "false"); /* or something... */ } printf("\nThe whole lot:\n"); } printa(@); } }(This would also allow you to, e.g., see the bottom ten by setting both }"aggsortrev" and "aggtop".) } }How does that sit? How about a new function that produces an aggregation with at most <n> elements, where <n> is the second argument: printa(agghead(@, 10)); ? --S
On Thu, Dec 22, 2005 at 02:27:47PM -0800, Seth Goldberg wrote:> > }Yeah, the way to do this would be via a new option. Something like > }"aggtop" or something? So your code would look like this: > } > } ... > } > } setopt("aggtop", "10"); > } printf("The top 10:\n"); > } printa(@); > } > } setopt("aggtop", "false"); /* or something... */ > } printf("\nThe whole lot:\n"); > } printa(@); > } > }(This would also allow you to, e.g., see the bottom ten by setting both > }"aggsortrev" and "aggtop".) > } > }How does that sit? > > How about a new function that produces an aggregation with at most <n> > elements, where <n> is the second argument: > > printa(agghead(@, 10));That''s what trunc does, effectively. (It just does it without creating a new aggregation.) Going beyond that would require aggregation assignment (i.e. "@a = @b"), which opens up a Pandora''s Box that we would prefer to keep welded shut. - Bryan -------------------------------------------------------------------------- Bryan Cantrill, Solaris Kernel Development. http://blogs.sun.com/bmc
On 12/23/05, Bryan Cantrill <bmc at eng.sun.com> wrote:> Yeah, the way to do this would be via a new option. Something like > "aggtop" or something? So your code would look like this: > > ... > > setopt("aggtop", "10"); > printf("The top 10:\n"); > printa(@); > > setopt("aggtop", "false"); /* or something... */ > printf("\nThe whole lot:\n"); > printa(@); > > (This would also allow you to, e.g., see the bottom ten by setting both > "aggsortrev" and "aggtop".) > > How does that sit?"aggtop" is something that is pretty close to the specific printa and will likely change for each printa''s. Some parameter setting within printa seems more appropriate than a global option. I''d prefer a syntax like: printa("%10a", @) or even printa(10@) Either way it is implemented, such a feature is certainly useful. -- Just me, Wire ...
On Fri, Dec 23, 2005 at 09:53:54AM +0800, Wee Yeh Tan wrote:> On 12/23/05, Bryan Cantrill <bmc at eng.sun.com> wrote: > > Yeah, the way to do this would be via a new option. Something like > > "aggtop" or something? So your code would look like this: > > > > ... > > > > setopt("aggtop", "10"); > > printf("The top 10:\n"); > > printa(@); > > > > setopt("aggtop", "false"); /* or something... */ > > printf("\nThe whole lot:\n"); > > printa(@); > > > > (This would also allow you to, e.g., see the bottom ten by setting both > > "aggsortrev" and "aggtop".) > > > > How does that sit? > > "aggtop" is something that is pretty close to the specific printa and > will likely change for each printa''s. Some parameter setting within > printa seems more appropriate than a global option.Then use setopt() to change the option between each printa(). The precedent here is the aggregation sorting and printing options that I just putback: aggsortrev, aggsortkey, aggsortpos, aggsortkeypos, etc.> I''d prefer a syntax like: > printa("%10a", @)That''s actually already valid D. If we had T-shirts, mugs, or any DTrace junk(*), I would offer it to the first person who can reply explaining what the above does, and using it in a valid script. (Note: valid, not useful.) - Bryan -------------------------------------------------------------------------- Bryan Cantrill, Solaris Kernel Development. http://blogs.sun.com/bmc (*) Trying (and failing) to resist the urge to point out the inverse correlation between quantity of such junk and timeliness of putback.
On 12/23/05, Bryan Cantrill <bmc at eng.sun.com> wrote:> Then use setopt() to change the option between each printa(). The precedent > here is the aggregation sorting and printing options that I just putback: > aggsortrev, aggsortkey, aggsortpos, aggsortkeypos, etc.Yeah, the problem here is "aggtop" likely change a lot more often than the other "agg*" that it might make sense to tie it with printa().> > I''d prefer a syntax like: > > printa("%10a", @) > > That''s actually already valid D. If we had T-shirts, mugs, or any DTrace > junk(*), I would offer it to the first person who can reply explaining what > the above does, and using it in a valid script. (Note: valid, not > useful.)*Smack face into the keyboard* That''s the width specifier. dtrace -n ''profile-1001{@[arg0]=count()}'' -n ''tick-5s{printa("%40a", @)}'' I had a tingle that something was off when I suggested that. -- Just me, Wire ...
On Fri, Dec 23, 2005 at 10:26:50AM +0800, Wee Yeh Tan wrote:> On 12/23/05, Bryan Cantrill <bmc at eng.sun.com> wrote: > > Then use setopt() to change the option between each printa(). The precedent > > here is the aggregation sorting and printing options that I just putback: > > aggsortrev, aggsortkey, aggsortpos, aggsortkeypos, etc. > > Yeah, the problem here is "aggtop" likely change a lot more often than > the other "agg*" that it might make sense to tie it with printa().We really don''t want to sully-up printa() with additional options; that''s what the option mechanism is for. (And I''m not even sure that I buy that one would want to change "aggtop" more than, say, "aggsortkey" or "aggsortrev" or whatever.) Or put it this way: we''ll implement "aggtop" as an option for now, and if you find you have zillions of scripts littered with "setopt("aggtop", "whatever")", we''ll talk about some syntactic sweetener...> > > I''d prefer a syntax like: > > > printa("%10a", @) > > > > That''s actually already valid D. If we had T-shirts, mugs, or any DTrace > > junk(*), I would offer it to the first person who can reply explaining what > > the above does, and using it in a valid script. (Note: valid, not > > useful.) > > *Smack face into the keyboard*Ouch! Careful... ;)> That''s the width specifier.Indeed it is.> dtrace -n ''profile-1001{@[arg0]=count()}'' -n ''tick-5s{printa("%40a", @)}''Right again. You and Seth Goldberg are our two winners. Mike: tell them what they win! (Oh right, nothing. Still, if we ever have something, you''ll win it. Honest.) - Bryan -------------------------------------------------------------------------- Bryan Cantrill, Solaris Kernel Development. http://blogs.sun.com/bmc
Robert Milkowski
2005-Dec-23 11:59 UTC
[dtrace-discuss] truncating aggregation output only
Hello Bryan, Thursday, December 22, 2005, 11:19:29 PM, you wrote: BC> On Fri, Dec 23, 2005 at 09:11:54AM +1100, Alan Hargreaves wrote:>> Robert Milkowski wrote: >> >Hello dtrace-discuss, >> > >> > Sometimes I want to run a script for some time and every n second >> > output N top entries. trunc() isn''t suitable here as it also removed >> > keys/values. I want it ''coz over time if I use sum() entries which >> > are normally truncated can actually get to top over a time. >> > >> > Maybe printa() extension, something like: printa(@b[10]) - to output >> > top 10? >> > >> >> Robert, that''s a really good idea. >> >> I worry about changing the syntax and overloading [] though. Perhaps a >> better idea would be to go the same way that we are doing column >> sorting? Bryan?BC> Yeah, the way to do this would be via a new option. Something like BC> "aggtop" or something? So your code would look like this: BC> ... BC> setopt("aggtop", "10"); BC> printf("The top 10:\n"); BC> printa(@); BC> setopt("aggtop", "false"); /* or something... */ BC> printf("\nThe whole lot:\n"); BC> printa(@); BC> (This would also allow you to, e.g., see the bottom ten by setting both BC> "aggsortrev" and "aggtop".) BC> How does that sit? This is good enough :) Additional option to printa would be easier/quicker to use but above example also solves the problem. I take it I do not have to fill RFE for it :) -- Best regards, Robert mailto:rmilkowski at task.gda.pl