Re: [PATCH] proc: speedup /proc/stat handling

From: Glauber Costa
Date: Mon Jan 23 2012 - 05:34:52 EST


On 01/23/2012 02:16 PM, KAMEZAWA Hiroyuki wrote:
On Fri, 20 Jan 2012 16:59:24 +0100
Eric Dumazet<eric.dumazet@xxxxxxxxx> wrote:

On a typical 16 cpus machine, "cat /proc/stat" gives more than 4096
bytes, and is slow :

# strace -T -o /tmp/STRACE cat /proc/stat | wc -c
5826
# grep "cpu " /tmp/STRACE
read(0, "cpu 1949310 19 2144714 12117253"..., 32768) = 5826<0.001504>


Thats partly because show_stat() must be called twice since initial
buffer size is too small (4096 bytes for less than 32 possible cpus)

Fix this by :

1) Taking into account nr_irqs in the initial buffer sizing.

2) Using ksize() to allow better filling of initial buffer.

3) Reduce the bloat on "intr ..." line :
Dont output trailing " 0" values at the end of irq range.

An alternative to 1) would be to remember the largest m->count reached
in show_stat()


nice catch. But how about using usual seq_file rather than single_open() ?
I just don't like multi-page buffer for this small file...very much.

A rough patch here, maybe optimization will not be enough. (IOW, this may be slow.)


I myself don't like it very much, at least at first sight.
Even with optimizations applied, I doubt we can make this approach faster than what we currently do for /proc/stat.

Also, the code gets a lot harder to read and grasp. Problem is, unlike most of the stuff using seq_file, /proc/stat shows a lot of different kinds of information, not a single kind of easily indexable information.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/