LWN.net Logo

De-bloating tracepoints

By Jonathan Corbet
May 5, 2010
Support for tracing in the Linux kernel has made great strides over the last couple of years. One of the key features of a mature tracing system, though, is a long list of well-defined, well-documented tracepoints which allow a system administrator to hook into kernel events without understanding the kernel code itself. The kernel has slowly been gaining those tracepoints, but, as Steven Rostedt has pointed out, there is a problem: each tracepoint adds something between 1KB and 5KB to the size of the kernel. When one starts to think about adding hundreds (or more) tracepoints, that overhead starts to add up.

Steven, of course, is as good a person as any to blame for this problem, so he has set out to fix it. His nine-part patch moves some information to shared locations and eliminates unneeded stuff; the result was a 100KB size reduction in the size of his kernel. Needless to say, this seems like a savings worth having; it makes it that much more likely that tracepoints will actually be enabled in production kernels.

Of course, most of us will have to take Steven's word for it that the patches make sense; they are written in that special dialect of C preprocessor macros that mere kernel hackers fear to touch. So most of us are likely to take the memory savings, but won't look too closely at how they are achieved.


(Log in to post comments)

De-bloating tracepoints

Posted May 6, 2010 5:55 UTC (Thu) by MisterIO (guest, #36192) [Link]

Only 100Kb by adding even more C preprocessor macros? Maybe it'd be interesting to know instead what's the actual saving on a per tracepoint basis. If instead 100Kb is a constant, because it's taken out of the infrastructure, IMO it's not worth it.

De-bloating tracepoints

Posted May 6, 2010 6:29 UTC (Thu) by dmk (subscriber, #50141) [Link]

From the Link provided in the artivcle (Steven's Patch):

Quote:

This patch series does not seem to affect TRACE_EVENT() much (had the same various sizes), but consistently brings DEFINE_EVENT()s down from 700 bytes to 250 bytes per DEFINE_EVENT(). Since syscalls use one "class" and are equivalent to DEFINE_EVENT() this can be a significant savings.

With events and syscalls (82 events and 616 syscalls), before this patch series, the size of vmlinux was: 16161794, and afterward: 16058182.

That is 103,612 bytes in savings! (over 100K)

Without tracing syscalls (82 events), it brought the size of vmlinux down from 1591046 to 15999394. 22,071 bytes in savings.

cheers, Flo

De-bloating tracepoints

Posted May 6, 2010 11:15 UTC (Thu) by MisterIO (guest, #36192) [Link]

Thanks for pointing that out, I should have definitely taken a look at the actual post before commenting. Well, from 700 to 250 bytes is clearly significant. Also, taking a look at the code, it doesn't seem as if it's becoming more complex, in fact he's mostly changing code which already had that form.

De-bloating tracepoints

Posted May 7, 2010 11:30 UTC (Fri) by nlucas (subscriber, #33793) [Link]

"1591046 to 15999394. 22,071 bytes in savings. "

Ok, I know it's a typo, but that's a 13,7 MB increase on my calculator ;-)

De-bloating tracepoints

Posted May 7, 2010 14:12 UTC (Fri) by ccurtis (guest, #49713) [Link]

I think that's more than a typo. I'm not sure what it is, but 1591xx to 1599xx -- no matter how many digits follow, isn't going to be a 22xx number, even if the numbers are swapped. If the numbers are swapped and the typo is that it's 1589xx, it still doesn't add up. This part of the statement is just bogus AFAICT.

De-bloating tracepoints

Posted May 10, 2010 13:43 UTC (Mon) by nevets (subscriber, #11875) [Link]

Nice catch!

Wow, this is what I get when I run the results on one machine and write it by hand on another. s/999/888/ and you get the correct number there. It was suppose to be 15888394. I was hitting the 9 key when I was suppose to be hitting the 8.

Here's the actually numbers (cut and paste):

text data bss dec hex filename
5554965 1012036 9343464 15910465 f2c641 vmlinux.orig
5535662 1009268 9343464 15888394 f2700a vmlinux.new

And now the numbers should add up:

$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
15910465 - 15888394
22071

De-bloating tracepoints

Posted May 10, 2010 18:16 UTC (Mon) by ccurtis (guest, #49713) [Link]

Of course - why would you transpose a single '9' for an '8' in a sequence of 3 '8's? I should have dug deeper, but I'm lazy. Maybe next time ... :-)

Copyright © 2010, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds