-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Limit number of generated BPF programs #2141
Conversation
5d6a200
to
62419e0
Compare
src/ast/passes/codegen_llvm.cpp
Outdated
std::to_string(probe_count_) + | ||
" BPF programs, which exceeds the current limit of " + | ||
std::to_string(bpftrace_.max_programs_) + | ||
" and it could take a long time.\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can leave this out. I'm more worried about the amount of system resources you end up stealing if you attach so many programs than it taking long
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed "take a long time" to "take a lot of resources" in docs. Should be ready for another review.
probe_count_ += matches.size(); | ||
if (probe_count_ > bpftrace_.max_programs_) | ||
{ | ||
throw std::runtime_error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using LOG(FATAL)
here might be nicer for the end user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't say, the exception is caught and translated to LOG(ERROR)
while LOG(FATAL)
will terminate the program with SIGABRT
which is not very user-friendly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah we catch it, nice :)
2c7c79e
to
28af20c
Compare
In some cases (e.g. when using the "probe" builtin), the number of generated BPF functions may be very large which may cause BPFtrace to hang. This change prevents that by setting a limit on the number of generated BPF functions. The limit can be changed using the BPFTRACE_MAX_BPF_PROGS environment variable.
28af20c
to
c0d7841
Compare
Originates from this comment.
In some cases (e.g. when using the
probe
builtin), the number of generated BPF functions may be very large which may cause bpftrace to hang. This is a safeguard that sets a limit of 512 BPF functions by default. The limit can be changed using theBPFTRACE_MAX_BPF_PROGS
environment variable.Checklist
man/adoc/bpftrace.adoc
and if needed indocs/reference_guide.md
CHANGELOG.md