public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] rearrange struct value to save memory
@ 2014-01-09 19:03 Tom Tromey
  2014-01-10  3:32 ` Yao Qi
  2014-01-16 21:54 ` Tom Tromey
  0 siblings, 2 replies; 6+ messages in thread
From: Tom Tromey @ 2014-01-09 19:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch rearranges struct value a tiny bit, moving the "regnum"
field into a hole.  This saves 8 bytes per value on a 64-bit machine,
and 4 bytes per value on a 32 bit machine.  I think it does not
negatively affect readability or performance.

Built and regtested on x86-64 Fedora 18.

Let me know what you think.

2014-01-09  Tom Tromey  <tromey@redhat.com>

	* value.c (struct value) <regnum>: Move earlier.
---
 gdb/ChangeLog | 4 ++++
 gdb/value.c   | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/gdb/value.c b/gdb/value.c
index 8542316..0e13b76 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -216,6 +216,9 @@ struct value
   /* If the value has been released.  */
   unsigned int released : 1;
 
+  /* Register number if the value is from a register.  */
+  short regnum;
+
   /* Location of value (if lval).  */
   union
   {
@@ -324,9 +327,6 @@ struct value
      taken off this list.  */
   struct value *next;
 
-  /* Register number if the value is from a register.  */
-  short regnum;
-
   /* Actual contents of the value.  Target byte-order.  NULL or not
      valid if lazy is nonzero.  */
   gdb_byte *contents;
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rearrange struct value to save memory
  2014-01-09 19:03 [PATCH] rearrange struct value to save memory Tom Tromey
@ 2014-01-10  3:32 ` Yao Qi
  2014-01-10 17:12   ` Tom Tromey
  2014-01-13 20:02   ` Tom Tromey
  2014-01-16 21:54 ` Tom Tromey
  1 sibling, 2 replies; 6+ messages in thread
From: Yao Qi @ 2014-01-10  3:32 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/10/2014 03:03 AM, Tom Tromey wrote:
> This patch rearranges struct value a tiny bit, moving the "regnum"
> field into a hole.  This saves 8 bytes per value on a 64-bit machine,
> and 4 bytes per value on a 32 bit machine.  I think it does not
> negatively affect readability or performance.
> 
> Built and regtested on x86-64 Fedora 18.
> 
> Let me know what you think.
> 

Hi, Tom,
It does save some memory shown by the result of 'make perf-check' on
an amd64-linux box.  I don't see any time performance regression
in the test.  It is indeed a good improvement!

                Original Patched
backtrace vmsize 2 55108 54316
backtrace vmsize 4 55108 52432
backtrace vmsize 8 53124 51512
backtrace vmsize 16 53124 51512
backtrace vmsize 32 53124 51512
backtrace vmsize 64 53124 51512
backtrace vmsize 128 53124 51512
backtrace vmsize 256 53124 51512
backtrace vmsize 512 53124 51512
backtrace vmsize 1024 53124 51512
backtrace vmsize 2048 53124 51512
disassemble vmsize 0 66740 66732
disassemble vmsize 1 66740 66732
disassemble vmsize 2 66740 66732
single-step vmsize 10000 50388 50384
single-step vmsize 20000 50652 50648
single-step vmsize 30000 51048 51044
single-step vmsize 40000 51312 51308
skip-prologue vmsize 1 50104 50100
skip-prologue vmsize 2 50104 50100
skip-prologue vmsize 3 50104 50100
solib_load vmsize 8 64968 64960
solib_load vmsize 16 64968 64960
solib_load vmsize 32 64968 64960
solib_load vmsize 64 64968 64960
solib_load vmsize 128 64968 64960
solib_unload vmsize 8 64972 64964
solib_unload vmsize 16 64972 64964
solib_unload vmsize 32 64972 64964
solib_unload vmsize 64 64972 64964
solib_unload vmsize 128 64972 64964

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rearrange struct value to save memory
  2014-01-10  3:32 ` Yao Qi
@ 2014-01-10 17:12   ` Tom Tromey
  2014-01-13 20:02   ` Tom Tromey
  1 sibling, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2014-01-10 17:12 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> It does save some memory shown by the result of 'make perf-check' on
Yao> an amd64-linux box.  I don't see any time performance regression
Yao> in the test.  It is indeed a good improvement!

Thanks Yao.
I'm sorry to report that it didn't even occur to me to try perf-check.
I'll give it a run here just so I can see it do its magic :)

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rearrange struct value to save memory
  2014-01-10  3:32 ` Yao Qi
  2014-01-10 17:12   ` Tom Tromey
@ 2014-01-13 20:02   ` Tom Tromey
  2014-01-14 13:50     ` Yao Qi
  1 sibling, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2014-01-13 20:02 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> It does save some memory shown by the result of 'make perf-check' on
Yao> an amd64-linux box.  I don't see any time performance regression
Yao> in the test.  It is indeed a good improvement!


Yao>                 Original Patched
Yao> backtrace vmsize 2 55108 54316
Yao> backtrace vmsize 4 55108 52432
Yao> backtrace vmsize 8 53124 51512
[...]


I tried perf-check out on another branch today.  I didn't see a canned
way to summarize the results, so I wrote the appended.  You'll need a
newish version of prettytable if you don't want the colorizing to mess
up the table.

This is still pretty dumb... I didn't try to deal with graphing or
anything cool like that.

Tom

#!/usr/bin/python

from termcolor import colored
import re
import fileinput
import prettytable

rx = re.compile('^(.*)\s([0-9.]+)$')

# Allow 5% noise.
NOISE = 0.05

results = {}

for line in fileinput.input():
    m = rx.match(line)
    if m:
        name = m.group(1)
        value = float(m.group(2))

        if name not in results:
            results[name] = []
        results[name].append(value)

keys = results.keys()
keys.sort()

tab = prettytable.PrettyTable()
for name in keys:
    vals = results[name]
    newvals = [name, str(vals[0])]
    for i in range(1, len(vals)):
        perc = abs((vals[i] - vals[i - 1]) / vals[i - 1])
        nv = str(vals[i])
        if perc > NOISE:
            if vals[i] > vals[i - 1]:
                nv = colored(nv, 'red')
            elif vals[i] < vals[i - 1]:
                nv = colored(nv, 'green')
        newvals.append(nv)

    tab.add_row(newvals)

print tab

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rearrange struct value to save memory
  2014-01-13 20:02   ` Tom Tromey
@ 2014-01-14 13:50     ` Yao Qi
  0 siblings, 0 replies; 6+ messages in thread
From: Yao Qi @ 2014-01-14 13:50 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/14/2014 04:02 AM, Tom Tromey wrote:
> I tried perf-check out on another branch today.  I didn't see a canned
> way to summarize the results, so I wrote the appended.  You'll need a
> newish version of prettytable if you don't want the colorizing to mess
> up the table.
> 
> This is still pretty dumb... I didn't try to deal with graphing or
> anything cool like that.

Yeah, we don't have scripts of this kind to compare the perf results,
but I think we need some.

At present, I am running perf tests continuously, and feed the result
to codespeed, in which the performance is shown as some diagrams.  I
open them in web browser every day, to see if there are any perf
regressions.  codespeed doesn't meet our needs perfectly, so I am
only running it in house and don't propose using it for GDB.

Performance data collection has been done, but perf data record
and comparison is still missing.  I've had some thoughts, but
incomplete.  I'll assemble them for a post to see how much we
can do here.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rearrange struct value to save memory
  2014-01-09 19:03 [PATCH] rearrange struct value to save memory Tom Tromey
  2014-01-10  3:32 ` Yao Qi
@ 2014-01-16 21:54 ` Tom Tromey
  1 sibling, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2014-01-16 21:54 UTC (permalink / raw)
  To: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> This patch rearranges struct value a tiny bit, moving the "regnum"
Tom> field into a hole.  This saves 8 bytes per value on a 64-bit machine,
Tom> and 4 bytes per value on a 32 bit machine.  I think it does not
Tom> negatively affect readability or performance.

Tom> Built and regtested on x86-64 Fedora 18.

I'm checking this in now.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-01-16 21:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-09 19:03 [PATCH] rearrange struct value to save memory Tom Tromey
2014-01-10  3:32 ` Yao Qi
2014-01-10 17:12   ` Tom Tromey
2014-01-13 20:02   ` Tom Tromey
2014-01-14 13:50     ` Yao Qi
2014-01-16 21:54 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).