Here are my ideas.

Can you look at fmgr_isbuiltin?  It is doing a binary search looking to
see if it is builtin.  Is it wrong?  Is there a better way to do this? 
Seems like a lot of cpu for this.

Also, locking seems to be taking quite a bit of cpu, especially if you
add up all the locking calls together.  Can you check and see if there
is a cleaner way to do this?
 
hash_search also looks like it could be improved.  This is called a lot
by the locking code.  I know because when I added real deadlock
detection, I had to work with this stuff.

---------------------------------------------------------------------------

Forwarded message:
> From maillist Thu Feb  5 15:11:14 1998
> Subject: Re: [HACKERS] Profile of current backend
> To: matti@algonet.se (Mattias Kregert)
> Date: Thu, 5 Feb 1998 15:11:14 -0500 (EST)
> Cc: meskes@topsystem.de, pgsql-hackers@postgreSQL.org
> In-Reply-To: <34DA19A1.14BD647E@algonet.se> from "Mattias Kregert" at Feb 5, 98 08:57:21 pm
> X-Mailer: ELM [version 2.4 PL25]
> MIME-Version: 1.0
> Content-Type: text/plain; charset=US-ASCII
> Content-Transfer-Encoding: 7bit
> Content-Length: 4140      
> 
> Interesting.  Nothing is jumping out at me.  Looks like we could try to
> clean up heapgettup() to see if there is anything in there that can be
> speeded up.
> 
> None of the calls looks like it should be inlined.  Do you see any that
> look good for inlining?
> 
> 
> > 
> > Meskes, Michael wrote:
> > >
> > > I take it some of you have already run the backend against a profiler.
> > > Could anyone please tell me which functions need works most?
> > 
> > SYSTEM: Linux 2.0.29, gcc 2.7.2
> > -------------------------------
> > [make distclean]
> > [CVSup'ed current source 1998-02-05]
> > [./configure]
> > [make]
> >   [CUSTOM_LDFLAGS not settable in Makefile.custom ...]
> >   [... setting LDFLAGS=-pg ins Makefile.global]
> > 
> >   --> fmgr.c: In function `fmgr_pl':
> >   --> fmgr.c:46: `fmgr_pl_finfo' undeclared (first use this function)
> >   [fix] cp backend/utils/fmgr.h backend/utils/fmgr/fmgr.h
> > 
> > [make install]
> > [Run initdb]
> > [Regression tests]
> >   strings .. failed [ok]
> >   lseg .. failed [new operator <= on lseg]
> >   horology .. failed [daylight savings error?]
> >   triggers .. failed
> >   select_views .. failed
> > 
> > 
> > PROFILE OF REGRESSION TEST:
> > ---------------------------
> >  time   seconds   seconds    calls  ms/call  ms/call  name    
> >  35.16      7.97     7.97                             mcount (profiler overhead)
> >   5.91      9.31     1.34     9924     0.14     0.20  heapgettup
> >   4.54     10.34     1.03   234597     0.00     0.01  hash_search
> >   2.12     10.82     0.48   151781     0.00     0.00  SpinAcquire
> >   2.03     11.28     0.46    46635     0.01     0.02  SearchSysCache
> >   1.63     11.65     0.37   171345     0.00     0.00  tag_hash
> >   1.46     11.98     0.33    20511     0.02     0.02  yylex
> >   1.41     12.30     0.32    31311     0.01     0.03  LockAcquire
> >   1.28     12.59     0.29     1522     0.19     0.61  yyparse
> >   1.24     12.87     0.28    41176     0.01     0.01  fmgr_isbuiltin
> >   1.01     13.10     0.23   201572     0.00     0.00  AllocSetAlloc
> >   0.84     13.29     0.19   186214     0.00     0.00  OrderedElemPop
> >   0.75     13.46     0.17    42896     0.00     0.00  nocachegetattr
> >   0.71     13.62     0.16    29869     0.01     0.04  LockRelease
> >   0.66     13.77     0.15   151781     0.00     0.00  SpinRelease
> >   0.66     13.92     0.15    88766     0.00     0.01  newNode
> >   0.66     14.07     0.15    52248     0.00     0.00  _bt_compare
> > ... around 1850 functions follows (0.66 - 0.0%)
> > 
> > heapgettup (called by, calling):
> > --------------------------------
> > index % time    self  children    called     name
> >                 0.01    0.01      96/9924        heap_markpos [448]
> >                 0.21    0.11    1566/9924        heap_restrpos [102]
> >                 1.12    0.58    8262/9924        heap_getnext [20]
> > [14]    13.8    1.34    0.69    9924         heapgettup [14]
> >                 0.04    0.14    9924/9924        RelationGetBufferWithBuffer [148]
> >                 0.03    0.15    5642/5702        ReleaseAndReadBuffer [145]
> >                 0.10    0.00   26276/42896       nocachegetattr [158]
> >                 0.01    0.08    7111/9607        HeapTupleSatisfiesVisibility [185]
> >                 0.04    0.00  117785/126582      char16eq [339]
> >                 0.02    0.00  111941/111994      int4eq [427]
> >                 0.02    0.00  109647/112329      nameeq [426]
> >                 0.00    0.01    1770/31585       ReleaseBuffer [134]
> >                 0.01    0.00   14000/50173       PageGetMaxOffsetNumber [341]
> >                 0.01    0.00    5185/5433        chareq [537]
> >                 0.01    0.00   15566/90147       BufferGetBlock [311]
> >                 0.01    0.00   17336/240911      BufferIsValid [207]
> >                 0.00    0.00       4/1973        int2eq [575]
> >                 0.00    0.00    7412/7412        nextpage [1186]
> >                 0.00    0.00     951/1358        SetBufferCommitInfoNeedsSave [1253]
> > --------------------------------
> > 
> > The *complete* gprof output is here:
> >   ftp://postgresql.org/pub/incoming/regression-profile-980205.gz 156k
> > 
> > /* m */
> > 
> > 
> 
> 
> -- 
> Bruce Momjian
> maillist@candle.pha.pa.us
> 


-- 
Bruce Momjian
maillist@candle.pha.pa.us

Thu, 5 Feb 1998 15:26:22 -0500 (EST)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] Profile of current backend (fwd)