News for hackers. Stuff that matters.
Re:Give me 15 minutes and I'll change your view of Linux tra... by haberman on Thursday September 28, 2017 @08:56PM (#15362000)
Argh. This talk reinforced my existing view of Linux tracing: it's really fragmented.

Five years ago I tried to make some sense of this by researching all of the existing technologies. In the kernel I found:

   - ftrace (https://lwn.net/Articles/290277/)
   - tracepoints (https://www.kernel.org/doc/Documentation/trace/tracepoints.txt)
   - kprobes (https://www.kernel.org/doc/Documentation/kprobes.txt)
   - events (https://www.kernel.org/doc/Documentation/trace/events.txt)
Now apparently we can add:

   - BPF, a packet filter that grew into a tracing framework
     (https://lwn.net/Articles/599755/)
In user-space we have:

   - perf
   - systemtap
   - lttng
   - other, random, fragmented things
This talk seems to add a bunch of other fragmented user-space tools.

I don't mean to put down anybody's work, but this stuff will never be user-friendly as long as it remains so fragmented, IMHO.

Re:Give me 15 minutes and I'll change your view of Linux tra... by xelxebar on Thursday September 28, 2017 @10:23PM (#15362314)
I'm of a similar mind. However, somewhat recently I came across this article which helped provide a framework to think about all these things. Turns it that it's not just a flat space of competing tools:

https://jvns.ca/blog/2017/07/05/linux-tracing-systems/

Re:Give me 15 minutes and I'll change your view of Linux tra... by haberman on Friday September 29, 2017 @01:28AM (#15362933)
Excellent post, thanks!
Re:Give me 15 minutes and I'll change your view of Linux tra... by brendangregg on Friday September 29, 2017 @02:40AM (#15363247)
It's not that bad.

- Some of those are not in-tree, like LTTng and SystemTap.

- Tracepoints, kprobes, events, and uprobes are all event libraries used by perf or ftrace, just like DTrace had multiple providers (fbt, pid, etc).

The real fragmentation is perf and ftrace, since both are in-tree front ends. That's not too bad, and they both have different strengths.

eBPF is weird in that it's neither an event library or a front end. It's programmatic capabilities. We're mostly using an out of tree project, bcc, to run it.

Re:Give me 15 minutes and I'll change your view of Linux tra... by db48x on Thursday September 28, 2017 @10:16PM (#15362293)
What's fragmented about it? Almost everything he showed there was a script that use ftrace, kprobes, or BPF to measure something specific. Since those are all available in the kernel at the same time, you can certainly think of them as a single API.
Re:Give me 15 minutes and I'll change your view of Linux tra... by lsd5you on Friday September 29, 2017 @04:07AM (#15363557)
So really it's a branding problem?
Re:Give me 15 minutes and I'll change your view of Linux tra... by db48x on Saturday September 30, 2017 @01:11AM (#15371356)
I wouldn't go that far; there are important differences between them.
Re:Give me 15 minutes and I'll change your view of Linux tra... by Sacho on Friday September 29, 2017 @12:09AM (#15362652)
I think lttng has kernel tracing. I don't know why the fragmentation you describe is "bad", though; it really depends on the tools themselves.

If there's just a variety of tools for the same task, then that's healthy competition and how you get better software.

If no single tool can fulfill all your tracing needs, that's still not necessarily a condemnation of the tools. It's entirely possible that each tool can complete a subset of tasks, but is significantly simpler to use as a result, so SUM(effort to learn tools you need) may still be comparable to the effort of a theoretical omni-tool.

Re:Give me 15 minutes and I'll change your view of Linux tra... by cyphar on Friday September 29, 2017 @01:16AM (#15362883)
He didn't mention this in this snippet, but the BCC (BPF Compiler Collection) intends to make this much simpler[1]. In particular it lets you write a tracer in Python (with the BPF program written in C) that attaches the BPF program to whatever types of probe points you like. So while internally there might be all this fragmentation a user shouldn't have to deal with it as much.

[1]: https://github.com/iovisor/bcc

Re:Give me 15 minutes and I'll change your view of Linux tra... by cryptonector on Saturday September 30, 2017 @12:02AM (#15371144)
Brendan used to be Mr. DTrace User. (Not Mr. DTrace -- that was bmc, ahl, and mws.) But the world isn't using Solaris or FreeBSD, so I guess he moved on like most of the rest of us Solaris diaspora. Still, every time I see one of Brendan's blogs I know, deep down, he must miss DTrace; I sure do. This video doesn't help me feel at home with Linux, but it's a resource for when I need to trace something. Mostly though, when I have to debug something on Linux, I do it the pre-DTrace way, which is to say: the hard way.
Re:Give me 15 minutes and I'll change your view of Linux tra... by thephyber on Friday September 29, 2017 @12:28AM (#15362717)
Isn't that kinda the ethos of Linux? Every program does one thing and does it well.
Re:Give me 15 minutes and I'll change your view of Linux tra... by X86BSD on Friday September 29, 2017 @12:55AM (#15362786)
No that's the UNIX philosophy. And Linux threw that out the window from day one. From file systems to solving /dev/poll and containers.
Re:Give me 15 minutes and I'll change your view of Linux tra... by cyphar on Friday September 29, 2017 @01:10AM (#15362853)
The good (and bad) thing about all of the technologies that make up "containers" on Linux is that they can be used by separate projects. Chromium uses seccomp, systemd uses namespaces and cgroups, a bunch of tools use AppArmor/SELinux.

But ultimately the reason that this is the current state is because of how Linux is developed. Trying to push something like Jails or Zones is an exercise in futility because the patchset would be too large, would touch everything, and the infrastructure would likely not be reusable by other people.

Re:Give me 15 minutes and I'll change your view of Linux tra... by alexnewman on Thursday September 28, 2017 @10:07PM (#15362248)
Some of those are old tools some are old. This will always be the case
Re:Give me 15 minutes and I'll change your view of Linux tra... by erikb on Thursday September 28, 2017 @05:14PM (#15360783)
okay, after 15 minutes of this.

Previous view: Linux tracing is so complicated. Without a personally important usecase I probably won't invest the time to learn it.

Current view: Linux tracing is so complicated. Without a personally important usecase I probably won't invest the time to learn it.

Soo... What I can say is I really hate these keyboard sounds. Otherwise I'm not sure I learned much.

Re:Give me 15 minutes and I'll change your view of Linux tra... by piyush_soni on Friday September 29, 2017 @12:24AM (#15362697)
And I'm jealous of his keyboard.
Re:Give me 15 minutes and I'll change your view of Linux tra... by johnrivera on Thursday September 28, 2017 @03:44PM (#15360127)
I can't help but giggle like a schoolchild because of those keyboard sounds.
Re:Give me 15 minutes and I'll change your view of Linux tra... by pmoriarty on Thursday September 28, 2017 @04:10PM (#15360312)
It was cute for about 2 seconds, then got incredibly annoying.
Re:Give me 15 minutes and I'll change your view of Linux tra... by vacri on Thursday September 28, 2017 @09:24PM (#15362081)
I get the feeling that it's more satisfying when it's on your own keyboard, but it's definitely annoying on another person's.
Re:Give me 15 minutes and I'll change your view of Linux tra... by ycombimike on Thursday September 28, 2017 @10:31PM (#15362344)
I'll bet he can't even hear it.
Re:Give me 15 minutes and I'll change your view of Linux tra... by justinjlynn on Friday September 29, 2017 @12:53AM (#15362777)
It's like playing a video game, I'd imagine. The sound effects are the bane of everyone's existence but your own. Seriously though, you don't play your _game boy_ in public without headphones; let alone present while playing one! I'm amazed -- so, so tempted to turn of the preso even if I was fascinated by the content.
Re:Give me 15 minutes and I'll change your view of Linux tra... by burkaman on Friday September 29, 2017 @12:33AM (#15362731)
He turns it on at the beginning and says it's because he likes having audio feedback.
Re:Give me 15 minutes and I'll change your view of Linux tra... by jachee on Thursday September 28, 2017 @04:16PM (#15360363)
Brenden Gregg was already my favorite Linux internals experts. This would've taken him to the top of the list if he weren't already there.
Re:Give me 15 minutes and I'll change your view of Linux tra... by kzahel on Thursday September 28, 2017 @04:07PM (#15360290)
Pretty funny. Found this in homebrew casks (https://github.com/yingDev/Tickeys)
Re:Give me 15 minutes and I'll change your view of Linux tra... by etblg on Friday September 29, 2017 @01:37PM (#15367355)
This is amazing. Now I'm swinging around a virtual sword every time I type.
Re:Give me 15 minutes and I'll change your view of Linux tra... by boondaburrah on Thursday September 28, 2017 @05:06PM (#15360704)
Suddenly I'm revisiting memories of Platinum Sounds.
Re:Give me 15 minutes and I'll change your view of Linux tra... by lotyrin on Thursday September 28, 2017 @04:08PM (#15360299)
BPF really seems nice. Ramifications to me though are: if I was willing to pay a few percent overhead on all my production instances, what I would be able to monitor 24/7 and get a return on the investment, and I haven't found much writing in that area.

Seems like there could be a lot of opportunity, hopefully I'll get a chance to dive in and find out myself.

Re:Give me 15 minutes and I'll change your view of Linux tra... by tomsthumb on Thursday September 28, 2017 @06:41PM (#15361383)
> I haven't found much writing in that area

This book would _probably_ get you moving in the right direction: http://www.brendangregg.com/sysperfbook.html

It should be something like: look at your bottlenecks and utilization, look at your costs, look at (cost effective) ways to reduce or remove those bottlenecks or that utilization. Pick the cheapest place to have a bottleneck. Using SSD at an extra 30$ a month lets you use half the CPU and RAM, saving 60$ a month? Go for it.

Re:Give me 15 minutes and I'll change your view of Linux tra... by pbhjpbhj on Thursday September 28, 2017 @05:14PM (#15360787)
It was on his blog before, http://www.brendangregg.com/blog/2016-12-27/linux-tracing-in... and has been posted here a couple of times. Interesting this is the most traction it's got AFAICS.
Re:Give me 15 minutes and I'll change your view of Linux tra... by Philipp__ on Friday September 29, 2017 @06:44AM (#15364160)
Or just learn DTrace and hope it will be eventually ported somehow to Linux... /s
Re:Give me 15 minutes and I'll change your view of Linux tra... by cryptonector on Friday September 29, 2017 @11:54PM (#15371126)
https://github.com/dtrace4linux/linux

I... haven't tried it in ages. I've no idea if it works. It used to crash my system easily, but maybe now it's fine.

Re:Give me 15 minutes and I'll change your view of Linux tra... by viraptor on Thursday September 28, 2017 @06:55PM (#15361473)
I feel like despite all this progress, sysdig is still the most accessible solution at the moment. It even includes a slowish, but super simple way of tracing user space (you can even write traces from bash scripts). I wish there was a built-in Linux equivalent.
Re:Give me 15 minutes and I'll change your view of Linux tra... by the8472 on Friday September 29, 2017 @11:10AM (#15365963)
perf with source annotation is pretty nice if you're profiling for individual hotspots. But I have not found any solution that lets me spot amdahl bottlenecks which get drowned out in raw cycles spent by the parallel parts. In java this is trivial with thread utilization timlines that incorporate sampling.

Maybe this could be solved by weighting samples by the inverse of number of running threads at the time

Re:Give me 15 minutes and I'll change your view of Linux tra... by chicago_wade on Thursday September 28, 2017 @06:01PM (#15361134)
Will BPF replace ftrace? From what I understood he was able to do everything ftrace could by using BPF and BPF was more efficient.
Re:Give me 15 minutes and I'll change your view of Linux tra... by cyphar on Friday September 29, 2017 @01:12AM (#15362867)
BPF was used to do the aggregation and calculation in-kernel. You still need ftrace to actually run the BPF program in that context. You can read the cover page for the patch that added this in 2015[1].

[1]: https://lwn.net/Articles/630965/

Re:Give me 15 minutes and I'll change your view of Linux tra... by brendangregg on Friday September 29, 2017 @05:21AM (#15363847)
Right; plus theres some capabilities where ftrace is (and maybe always will be) better. Eg, function counting: ftrace can count all kernel functions instantly (try my perf-tools funccount tool), whereas the BPF method involves setting a kprobe on everything, which takes much longer (setup and tear down). And function graph tracing from ftrace will likely be better than anything we can do in BPF (as it uses tracing all functions as well).
Re:Give me 15 minutes and I'll change your view of Linux tra... by wyldfire on Thursday September 28, 2017 @04:19PM (#15360386)
perf is awesome. ftrace is awesomer still for finding great stuff but I'm often on a system with a kernel with no or limited support enabled for it.