lkml.org 
[lkml]   [2012]   [Jan]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] proc: speedup /proc/stat handling
On 01/23/2012 02:16 PM, KAMEZAWA Hiroyuki wrote:
> On Fri, 20 Jan 2012 16:59:24 +0100
> Eric Dumazet<eric.dumazet@gmail.com> 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.




\
 
 \ /
  Last update: 2012-01-23 11:37    [W:0.087 / U:3.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site