[PATCH RFC] roll our own printf implementation

Denys Vlasenko dvlasenk at redhat.com
Fri Mar 30 11:11:14 UTC 2012


Hi,

Glibc printf is not fast, and we use it A LOT for log formatting,
so I experimented with replacing it with kernel's one.

We don't do any Unicode and weird conversion things, so we can cut
a few corners and be faster.

Attached is the first quick attempt at this code.

It can be sped up a bit more. For example, length checks
in kernel_vsnprintf can be simplified (we don't need
to be precise there, it's ok to report overflow spuriously).
We never emit uppercase hex numbers, can simplify that code too.

Testing: I run
time ./strace -o/dev/null ./strace -o/dev/null ./strace -o/dev/null ./strace -o/dev/null ./strace -o/dev/null true
several times, results:

Before:
user    0m5.517s
user    0m5.589s
user    0m7.070s
user    0m7.072s
user    0m7.140s
user    0m7.151s
user    0m7.191s
user    0m7.255s
After:
user    0m4.087s
user    0m6.641s
user    0m6.658s
user    0m6.740s
user    0m6.746s
user    0m6.794s
user    0m6.799s
user    0m6.908s

As you see, the win is there, but it is not particularly big.

What do you guys think? Is it even worth doing?
-- 
vda

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 35.patch
Type: text/x-patch
Size: 22720 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20120330/63016bf7/attachment.bin>


More information about the Strace-devel mailing list