AllocSetReset improvement - Mailing list pgsql-patches

From a_ogawa
Subject AllocSetReset improvement
Date
Msg-id PIEMIKOOMKNIJLLLBCBBCEPICGAA.a_ogawa@hi-ho.ne.jp
Whole thread Raw
Responses Re: AllocSetReset improvement  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
In SQL that executes aggregation, AllocSetReset is called many times and
spend a lot of cycles.
This patch saves the cycles spent by AllocSetReset.

An idea of the patch is to add a flag to AllocSetContext. This flag
shows whether AllocSetReset should work.

The effect of the patch that I measured is as follows:

o Data for test was created by 'pgbench -i -s 5'.

o Test SQL:
select b.bid, sum(a.abalance), avg(a.abalance)
from accounts a, branches b
where a.bid = b.bid
group by b.bid;

o I measured time that executed the SQL ten times.
(1)Linux(CPU: Pentium III, Compiler option: -O2)
 - original: 31.310s
 - patched : 28.812s

(2)Linux(CPU: Pentium 4, Compiler option: -O2)
 - original: 8.953s
 - patched : 7.753s

(3)Solaris(CPU: Ultra SPARC III, Compiler option: -O2)
 - original: 41.8s
 - patched : 38.6s

o gprof result(Linux, Compiler option: -O2 -pg -DLINUX_PROFILE)
- original
Each sample counts as 0.01 seconds.
  %   cumulative  self            self   total
 time   seconds  seconds    calls s/call s/call  name
  9.20      3.06    3.06 38500155   0.00   0.00  AllocSetReset
  8.99      6.05    2.99 27500055   0.00   0.00  slot_deform_tuple
  7.40      8.51    2.46 44000000   0.00   0.00  slot_getattr
  4.81     10.11    1.60 27500110   0.00   0.00  ExecEvalVar
  3.64     11.32    1.21 38500143   0.00   0.00  MemoryContextReset
  3.64     12.53    1.21  6007086   0.00   0.00  LWLockRelease
  3.31     13.63    1.10  5500079   0.00   0.00  heapgettup

- patched
Each sample counts as 0.01 seconds.
  %   cumulative  self            self   total
 time   seconds  seconds    calls s/call s/call  name
  8.76      2.82    2.82 27500055   0.00   0.00  slot_deform_tuple
  7.73      5.31    2.49 44000000   0.00   0.00  slot_getattr
  4.72      6.83    1.52 27500110   0.00   0.00  ExecEvalVar
  4.32      8.22    1.39  5500011   0.00   0.00  ExecHashJoin
  4.28      9.60    1.38  6007086   0.00   0.00  LWLockRelease
  4.04     10.90    1.30 38500143   0.00   0.00  MemoryContextReset
  3.63     12.07    1.17  5500079   0.00   0.00  heapgettup
  3.04     13.05    0.98  5499989   0.00   0.00
ExecMakeFunctionResultNoSets
  2.67     13.91    0.86  5500110   0.00   0.00  ExecProject
  2.61     14.75    0.84 11000000   0.00   0.00  advance_transition_function
  2.55     15.57    0.82 38500155   0.00   0.00  AllocSetReset

regards,

---
Atsushi Ogawa

Attachment

pgsql-patches by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: lastval()
Next
From: Bruce Momjian
Date:
Subject: Re: [BUGS] BUG #1588: pg_autovacuum sleep parameter overflow