peter.memishian at sun.com
2006-Sep-20 06:40 UTC
[dtrace-discuss] committing multiple speculations in a single probe
While using DTrace to track down a problem recently, we came across an
unexpected restriction: the compiler will not permit different
speculations to be committed in the same instance of a probe identifier.
For instance, consider the following useless D script:
#!/usr/sbin/dtrace -s
#pragma D option nspec=2
BEGIN {
spec1 = speculation();
spec2 = speculation();
}
END {
commit(spec1);
commit(spec2);
}
# ./spec.d
dtrace: failed to compile script ./spec.d: line 12: commit( ) may
not follow commit( )
However, if the script is changed to:
#!/usr/sbin/dtrace -s
#pragma D option nspec=2
BEGIN {
spec1 = speculation();
spec2 = speculation();
}
END {
commit(spec1);
}
END {
commit(spec2);
}
... then it compiles without issue. Is this restriction intentional?
Thanks!
--
meem
peter.memishian at sun.com
2006-Sep-20 12:26 UTC
[dtrace-discuss] committing multiple speculations in a single probe
[ Apologies if this is a duplicate; I''m having some MTA issues. ]
While using DTrace to track down a problem recently, we came across an
unexpected restriction: the compiler will not permit different
speculations to be committed in the same instance of a probe identifier.
For instance, consider the following useless D script:
#!/usr/sbin/dtrace -s
#pragma D option nspec=2
BEGIN {
spec1 = speculation();
spec2 = speculation();
}
END {
commit(spec1);
commit(spec2);
}
# ./spec.d
dtrace: failed to compile script ./spec.d: line 12: commit( ) may
not follow commit( )
However, if the script is changed to:
#!/usr/sbin/dtrace -s
#pragma D option nspec=2
BEGIN {
spec1 = speculation();
spec2 = speculation();
}
END {
commit(spec1);
}
END {
commit(spec2);
}
... then it compiles without issue. Is this restriction intentional?
Thanks!
--
meem
Bryan Cantrill
2006-Sep-20 23:01 UTC
[dtrace-discuss] committing multiple speculations in a single probe
> However, if the script is changed to: > > #!/usr/sbin/dtrace -s > > #pragma D option nspec=2 > > BEGIN { > spec1 = speculation(); > spec2 = speculation(); > } > > END { > commit(spec1); > } > END { > commit(spec2); > } > > ... then it compiles without issue. Is this restriction intentional?I don''t know if I''d say "intentional" -- more like "unfortunate." The issues here are very grotty low-level details, but suffice it to say that it''s not trivial to allow multiple commit()s in a single clause without opening up a can of worms (or perhaps a duffle bag of snakes is a more apt metaphor). If this particular case is really bothering you, we might be able to find a way to address it -- but in general commit() doesn''t play well with other actions in the same clause, and it''s likely that there will always be restrictions of one sort or another... - Bryan -------------------------------------------------------------------------- Bryan Cantrill, Solaris Kernel Development. http://blogs.sun.com/bmc
peter.memishian at Sun.COM
2006-Sep-21 03:09 UTC
[dtrace-discuss] committing multiple speculations in a single probe
> > ... then it compiles without issue. Is this restriction intentional?> > I don''t know if I''d say "intentional" -- more like "unfortunate." The > issues here are very grotty low-level details, but suffice it to say that > it''s not trivial to allow multiple commit()s in a single clause without > opening up a can of worms (or perhaps a duffle bag of snakes is a more apt > metaphor). If this particular case is really bothering you, we might be > able to find a way to address it -- but in general commit() doesn''t play > well with other actions in the same clause, and it''s likely that there > will always be restrictions of one sort or another... Understood. Given that there''s a viable workaround, it''s not a bother. However, would it be possible to explicitly state in the DTrace Guide that committing multiple speculations in the same clause is unsupported? -- meem