482 points · by okket · 10y ago · 81 comments
DTrace, SystemTap and eBPF/BCC are designed to aggregate data in the critical path and compute a summary of the activity. Ftrace and LTTng are designed to extract traces of execution for high resolution post-processing with as small overhead as possible.
Aggregation is very powerful and gives a quick overview of the current activity of the system. Tracing extracts the detailed activity at various levels and allows in-depth understanding of a particular behaviour after the fact by allowing to run as many analyses as necessary on the captured trace.
In terms of impact on the traced system, trace buffering scales better with the number of cores than aggregation approaches due its ability to partition the trace data into per-core buffers.
Both approaches have upsides and downsides and should not be seen as being in competition, they address different use-cases and can even complement each other.
I think the two models for tracers, playing on their strengths, are: 1. real-time analysis tracers (DTrace/stap/BPF), and 2. offline analysis tracers (LTTng, sysdig). Both can do the other as well, but I'm just pointing out strengths.
sysdig (and I believe LTTng) has done great work at creating capture files that can then be analyzed offline in many many different ways, and they've optimized the way full-event dumps can be captured and saved (which I know LTTng has done as well). DTrace/stap/BPF don't have any offline capture file capabilities -- they could do it, but it's not been their focus.
Seeing the tracing capabilites of Linux expand is exciting indeed.
Edit: the couple of tutorials that finally unlocked DTrace (on OS X) for me are:
I once try to debug the open source libusb app in Mac OS, with DTrace I can trace the App, Kernel USB API call, libusb internal thread in user space, etc.
Much better visibility to system activities compare to simple strace.
Absolutely love the power of what it can do.
BTW, Can a DTrace script to use to monitor a system with potential "Dirty COW" type privilege escalation issue?
The good thing is this is solved simply by waiting long enough. The bad thing is most developers can't just pick this up today without a bunch of extra effort.
If you are looking for something you can use with old kernels you should definitely checkout Brendan's perf-tools repo[1]. It takes advantage of older kernel features and works with things as old as ubuntu 12.04.
*Edit: Fixed Brendan's name
Since 4.9 is supposed to be the next LTS, if it gets out of RC fast enough, we could see 4.9 in the 2017.03 Amazon Linux AMI, which would be a pretty big win for those of us running workloads in the AWS cloud.
The Linux kernel is the most safe operating system component to upgrade, mostly because the Linux kernel people care deeply about compatibility and not breaking user space. While it is still not free to upgrade, the cost is minimal compared to the cost (in real money, risk, security) of backporting major components to older kernels, like Red Hat is doing.
Red Hat is maintaining old kernels for having a stable kernel ABI (among some other reasons), not for general "stability".
Personally I run only CentOS, but always with a recent kernel, albeit usually a LTS one. Mostly to get exactly these type of features described in this article.
> On Linux, some out-of-tree tracers like SystemTap could serve these needs, but brought their own challenges.
I was pretty happy with stap, it had a really rich feature set.
> DTrace has its own concise language, D, similar to awk, whereas bcc uses existing languages (C and Python or lua) with libraries.
I think we need more creative names for languages. The short and simple ones like "go" and "D" keep on having collisions. :)
>BPF adds ... uprobes
uprobes + all the other stuff is really killer, I like the idea of watching for stuff like "my app has crossed this threshold and then this system condition occurs". At least when I tried it a couple years ago with stap my kernel wasn't built with uprobes support and I wasn't inclined to rebuild it. Hopefully it becomes (or has become) more mainstream.
So are other companies. I mentioned it in the post, as in a way this hurt BPF development, as companies that normally would have contributed resources said they were satisfied with stap. Exciting times might be ahead for stap, if it continues its BPF backend.
As for naming, yes, we need better names. Maybe the bcc/Python/BPF combination can be named something?
DTrace made this really nice, because you would write your tracing scripts in a high-level, awk-like language, which is the sort of thing well-suited to the purpose.
Think of the current bcc/Python/C interface as a lightweight skin that was necessary during BPF development to kick the tires on various features, prototype tools, see what else needed to be done, etc. It may be good enough to stay around, as lots of tools have been written for it that will get used and be valuable. But there's room for higher-level languages too.
If Sasha keeps developing his "trace" tool (and its summary counterpart, argdist), that may serve many such custom needs (as another option). See the various examples: https://github.com/iovisor/bcc/blob/master/tools/trace_examp... , like:
# trace 'sys_read (arg3 > 20000) "read %d bytes", arg3'
TIME PID COMM FUNC -
05:18:23 4490 dd sys_read read 1048576 bytes
05:18:23 4490 dd sys_read read 1048576 bytes
05:18:23 4490 dd sys_read read 1048576 bytesIf we have some kind of spec (even if it's not formal), it might be possible, since they are roughly equivalent, AFAIK. However, since I haven't worked in-depth in either, I'm unsure what work would be involved: it's possible that only a subset would compile.
Anyways, this is probably a good goal to shoot for. Dtrace is the system tracer on pretty much all of the other big unixes, so it's a good idea to support as much of its language as possible. Plus, there are a lot of scripts already written in DTrace's language: having access to them would be invaluable.
See https://github.com/iovisor/bcc/blob/master/src/lua/README.md... or examples https://github.com/iovisor/bcc/blob/master/examples/lua/trac... (this one is for tracing).
It also allows for building higher level APIs atop BCC's low-level lua integration, as opposed to writing yet another DSL.
But what would you expect for software coming out of Red Hat? Their projects are usually a mixed bag at best.
It's a shame. One of the nice things about dtrace was that there was a book on it. Good, in-depth documentation on performance tools is hard to find.
BTW, I wouldn't say "maybe" regarding BPF, as it's integrated in the Linux kernel (unlike most of the other tracers, which are add-ons). Sooner or later everyone who runs Linux is getting it.
Things have been moving so fast it's probably a good thing you didn't. It sounds like 4.9 will slow a lot of that down to a more manageable pace for writing a book, though.
I thought Netflix was mostly running FreeBSD [1]. Is it only the Open Connect Appliance?
It only seems that way. We're never stuck with something as long as we don't accept it. One other factor is at play which works against Linux, and that is that people in IT like shiny new things, and therefore something else always comes along. Hopefully this time around, that something else will be the old new thing (learning from the past, and re-discovery). One way or the other, the clock is ticking on Linux, and one of these days, it won't be as popular any more, because something else will be the new-new thing. It's the nature of this industry:
change is the only constant.
You don't have to accept anything. Don't bow to peer pressure.
BPF can take advantage of uprobes and instrument around them, but it interacts with them, and does not replace them