Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1457442

Re: [PATCH] proc: faster /proc/*/status

From Alexey Dobriyan <adobriyan@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] proc: faster /proc/*/status
Date 2016-08-07 11:00 +0200
Message-ID <s3s65-1ub-5@gated-at.bofh.it> (permalink)
References <s3hDI-2QM-3@gated-at.bofh.it> <s3mN3-6xA-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, Aug 06, 2016 at 08:16:27PM -0700, Andi Kleen wrote:
> Alexey Dobriyan <adobriyan@gmail.com> writes:
> > -
> > +	seq_printf(m, "State:\t%s", get_task_state(p));
> > +
> > +	seq_puts(m, "\nTgid:\t");
> 
> The only different should be the format string.
> 
> Scanning the format string really shouldn't be that expensive?!?

Surprise, it is (see my reply to Al).

What seq_put_decimal_ull() did is the equivalent of

	seq << "foo";
	seq << bar;
	seq << '\n';

No precisions, not widths, no padding, no upper and lowercasing.

> It would be better if you could find out why that is slow and optimize
> it. Then you would benefit every seq_printf user, not just this
> special case.
> 
> Perhaps it could benefit from some of the bit masking tricks to
> scan the string with wider tests than a word.

And then what? Parsing format string is still be there.

This is first line of profile of the first function (format_decode)

       │     static noinline_for_stack
       │     int format_decode(const char *fmt, struct printf_spec *spec)
       │     {
 10.38 │       push   %rbp			<===
  1.07 │       mov    %rsp,%rbp
  1.09 │       push   %r12
  4.51 │       mov    %rsi,%r12
  1.40 │       push   %rbx
  1.86 │       mov    %rdi,%rbx
       │       sub    $0x8,%rsp

It is so bloated that gcc needs to be asked to not screw up with stack
size.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] proc: faster /proc/*/status Alexey Dobriyan <adobriyan@gmail.com> - 2016-08-06 23:50 +0200
  Re: [PATCH] proc: faster /proc/*/status Joe Perches <joe@perches.com> - 2016-08-07 00:50 +0200
    [PATCH] seq/proc: Modify seq_put_decimal_[u]ll to take a const char *, not char Joe Perches <joe@perches.com> - 2016-08-09 05:10 +0200
  Re: [PATCH] proc: faster /proc/*/status Andi Kleen <andi@firstfloor.org> - 2016-08-07 05:20 +0200
    Re: [PATCH] proc: faster /proc/*/status Alexey Dobriyan <adobriyan@gmail.com> - 2016-08-07 11:00 +0200
      Re: [PATCH] proc: faster /proc/*/status Andi Kleen <andi@firstfloor.org> - 2016-08-07 19:00 +0200
        Re: [PATCH] proc: faster /proc/*/status Joe Perches <joe@perches.com> - 2016-08-07 19:40 +0200
          Re: [PATCH] proc: faster /proc/*/status Andi Kleen <andi@firstfloor.org> - 2016-08-07 19:50 +0200
            Re: [PATCH] proc: faster /proc/*/status Joe Perches <joe@perches.com> - 2016-08-07 23:30 +0200
              Re: [PATCH] proc: faster /proc/*/status Andrew Morton <akpm@linux-foundation.org> - 2016-08-10 01:30 +0200
                [RFC PATCH] meminfo: Break apart a very long seq_printf with #ifdefs Joe Perches <joe@perches.com> - 2016-08-10 20:30 +0200

csiph-web