All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf: replace automatic const char[] variables by statics
Date: Fri, 11 Jan 2019 10:32:02 -0300	[thread overview]
Message-ID: <20190111133202.GS22483@kernel.org> (raw)
In-Reply-To: <20181102230624.20064-1-linux@rasmusvillemoes.dk>

Em Sat, Nov 03, 2018 at 12:06:23AM +0100, Rasmus Villemoes escreveu:
> An automatic const char[] variable gets initialized at runtime, just
> like any other automatic variable. For long strings, that uses a lot of
> stack and wastes time building the string; e.g. for the "No %s
> allocation events..." case one has
> 
>   444516:       48 b8 4e 6f 20 25 73 20 61 6c   movabs $0x6c61207325206f4e,%rax # "No %s al"
>   ...
>   444674:       48 89 45 80                     mov    %rax,-0x80(%rbp)
>   444678:       48 b8 6c 6f 63 61 74 69 6f 6e   movabs $0x6e6f697461636f6c,%rax # "location"
>   444682:       48 89 45 88                     mov    %rax,-0x78(%rbp)
>   444686:       48 b8 20 65 76 65 6e 74 73 20   movabs $0x2073746e65766520,%rax # " events "
>   444690:       66 44 89 55 c4                  mov    %r10w,-0x3c(%rbp)
>   444695:       48 89 45 90                     mov    %rax,-0x70(%rbp)
>   444699:       48 b8 66 6f 75 6e 64 2e 20 20   movabs $0x20202e646e756f66,%rax
> 
> Make them all static so that the compiler just references objects in .rodata.
> 

Ok, using dwarves's codiff tool:

  $ codiff --functions /tmp/perf.before ~/bin/perf
builtin-sched.c:
  cmd_sched                 |  -48
 1 function changed, 48 bytes removed, diff: -48

builtin-report.c:
  cmd_report                |  -32
 1 function changed, 32 bytes removed, diff: -32

builtin-kmem.c:
  cmd_kmem                  |  -64
  build_alloc_func_list     |  -50
 2 functions changed, 114 bytes removed, diff: -114

builtin-c2c.c:
  perf_c2c__report          | -390
 1 function changed, 390 bytes removed, diff: -390

ui/browsers/header.c:
  tui__header_window        | -104
 1 function changed, 104 bytes removed, diff: -104

/home/acme/bin/perf:
 9 functions changed, 688 bytes removed, diff: -688

Thanks, applied.

- Arnaldo

  parent reply	other threads:[~2019-01-11 13:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-02 23:06 [PATCH] perf: replace automatic const char[] variables by statics Rasmus Villemoes
2018-11-04 19:26 ` Jiri Olsa
2019-01-10 21:12   ` Rasmus Villemoes
2018-11-04 21:52 ` [PATCH] checkpatch: Warn on const char foo[] = "bar"; declarations Joe Perches
2019-01-11 13:32 ` Arnaldo Carvalho de Melo [this message]
2019-01-22 10:09 ` [tip:perf/core] perf tools: Replace automatic const char[] variables by statics tip-bot for Rasmus Villemoes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190111133202.GS22483@kernel.org \
    --to=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.