Re: [PATCH] Add num_to_str() for speedup /proc/stat

From: KAMEZAWA Hiroyuki
Date: Mon Jan 30 2012 - 18:59:46 EST


On Mon, 30 Jan 2012 15:20:51 -0800
Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:

> On Mon, 30 Jan 2012 14:16:19 +0900
> KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:
>
> > From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> > Date: Mon, 30 Jan 2012 14:15:12 +0900
> > Subject: [PATCH] Add num_to_str() for speedup /proc/stat
> > On my 8cpu box.
> > == Before patch ==
> > [root@bluextal test]# time ./stat_check.py
> >
> > real 0m0.150s
> > user 0m0.026s
> > sys 0m0.121s
> >
> > == After patch ==
> > [root@bluextal test]# time ./stat_check.py
> >
> > real 0m0.055s
> > user 0m0.022s
> > sys 0m0.030s
> >
> > Maybe it's worth to add this simple function.
>
> I suppose so - the new infrastructure can be used elsewhere.
>
> I tried doing the
>
> if (kstst_irqs(j) == 0) {
> seq_putc(p, ' ');
> seq_putc(p, '0');
>
> think on top of this and didn't observe any improvement.
>
>
> I made some changes - please review. I'm not sure why you did "char
> tmp[66]"?
>
Your fix seems fine to me.
I'm sorry I copied tmp[66] from number()..

and yes, 0xffffffffffffffff=18446744073709551615 , tmp[21] will be enough.

I'll prepare patch for /proc/<pid>/stat and see 'ps' and 'top' performance.

Thanks,
-Kame

--
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/