-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't print out maps on exit if END probe is defined #3147
Comments
Agreed that current behavior is kinda annoying. But could be risky. There might be automated users (eg https://github.com/iovisor/kubectl-trace and others) that rely on the exit printing. If we change the behavior they could lose stats. |
Actually, current behavior is beneficial for one liners. Which is probably why it’s like this in the first place |
I agree with @danobi here. The "feature" has been around for a long time and many automated users of bpftrace may rely on it. What about we introduced a config option (and possibly a CLI option) that would auto-clear all the maps prior to exiting? |
One liners wouldn't typically define an For these automated users, do we know if they are they defining their own end probes or not? I've just gone through and analysed Meta's collection of bpftrace scripts and the proportions are similar to the bpftrace tools in this repo:
So ~7% of scripts will break with this change. Of those, I think a lot could be improved by explicitly printing the maps they care about instead of the inverse (deleting those they don't want to see). Instead of this:
It'd be both clearer and shorter as:
This behaviour could be toggled with a config option, but I think it should be made the default at some point as based on |
I agree that auto printing of maps at the end is blah AND that maybe too many people might rely on this default behavior to change it (at least without a lot of notice). What about instead of implicit map clearing with |
I think we could even do both However, having a |
If the
END
probe is defined, don't print out maps automatically when bpftrace exits.This will change the behaviour of some existing scripts, so could do with a discussion.
I often see the
END
probe being used solely toclear()
all maps so that they're not printed by bpftrace, e.g.:bpftrace/tools/biosnoop.bt
Lines 48 to 54 in c8fd334
It's tedious to write this in most scripts and keep the list of maps to be cleared up-to-date as the script evolves.
Analysing the current state of the bpftrace tools, 18 scripts use
END
to clear maps and 18 rely on the implicit printing without specifying anEND
probe. 3 scripts define andEND
probe and also rely on the implicit printing. They all take the form:bpftrace/tools/bitesize.bt
Lines 26 to 29 in c8fd334
But I think this would be better if they explicitly printed out the relevant map anyway, instead of relying on the implicit print-on-exit behaviour.
The text was updated successfully, but these errors were encountered: