Re: Binary search in fmgr_isbuiltin() is a bottleneck.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Jeevan Ladhe <jeevan(dot)ladhe(at)enterprisedb(dot)com>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Binary search in fmgr_isbuiltin() is a bottleneck.
Date: 2017-09-28 18:59:45
Message-ID: 12940.1506625185@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> [ we should use an index array ]

Just to prove the point, I threw together the attached trivial test case,
which time-trials the existing fmgr_isbuiltin implementation against both
the proposed hash implementation and a simple index array. On my machine,
with a repeat count of 10000, I get

NOTICE: bsearch runtime 4234.087 ms
NOTICE: hash runtime 2542.636 ms
NOTICE: index runtime 165.184 ms

(These numbers are repeatable within 1% or so.)

It could be argued that trialling OIDs sequentially gives a bit of an
unfair advantage to the bsearch and index methods over the hash method,
because the former are going to suffer fewer cache misses that way.
But I don't see a randomized lookup order changing the conclusion much.

regards, tom lane

Attachment Content-Type Size
testruntime.c text/x-c 3.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-09-28 19:03:38 Re: Domains and arrays and composites, oh my
Previous Message Andrew Dunstan 2017-09-28 18:58:00 Re: Domains and arrays and composites, oh my