From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Improve hash_create's API for selecting simple-binary-key hash f
Date: Thu, 18 Dec 2014 18:36:45 +0000
Message-ID: <E1Y1fwL-0001Fv-Lw@gemulon.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>
Improve hash_create's API for selecting simple-binary-key hash functions.
Previously, if you wanted anything besides C-string hash keys, you had to
specify a custom hashing function to hash_create(). Nearly all such
callers were specifying tag_hash or oid_hash; which is tedious, and rather
error-prone, since a caller could easily miss the opportunity to optimize
by using hash_uint32 when appropriate. Replace this with a design whereby
callers using simple binary-data keys just specify HASH_BLOBS and don't
need to mess with specific support functions. hash_create() itself will
take care of optimizing when the key size is four bytes.
This nets out saving a few hundred bytes of code space, and offers
a measurable performance improvement in tidbitmap.c (which was not
exploiting the opportunity to use hash_uint32 for its 4-byte keys).
There might be some wins elsewhere too, I didn't analyze closely.
In future we could look into offering a similar optimized hashing function
for 8-byte keys. Under this design that could be done in a centralized
and machine-independent fashion, whereas getting it right for keys of
platform-dependent sizes would've been notationally painful before.
For the moment, the old way still works fine, so as not to break source
code compatibility for loadable modules. Eventually we might want to
remove tag_hash and friends from the exported API altogether, since there's
no real need for them to be explicitly referenced from outside dynahash.c.
Teodor Sigaev and Tom Lane
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/4a14f13a0abfbf7e7d44a3d2689444d1806aa9dc
Modified Files
--------------
contrib/pg_trgm/trgm_regexp.c | 3 +-
contrib/postgres_fdw/connection.c | 3 +-
src/backend/access/gist/gistbuild.c | 4 +--
src/backend/access/gist/gistbuildbuffers.c | 6 ++--
src/backend/access/heap/rewriteheap.c | 8 ++---
src/backend/access/transam/xlogutils.c | 3 +-
src/backend/commands/sequence.c | 3 +-
src/backend/nodes/tidbitmap.c | 3 +-
src/backend/optimizer/util/predtest.c | 3 +-
src/backend/parser/parse_oper.c | 3 +-
src/backend/postmaster/autovacuum.c | 6 ++--
src/backend/postmaster/checkpointer.c | 3 +-
src/backend/postmaster/pgstat.c | 21 +++++--------
src/backend/replication/logical/reorderbuffer.c | 9 ++----
src/backend/storage/buffer/buf_table.c | 3 +-
src/backend/storage/buffer/bufmgr.c | 3 +-
src/backend/storage/buffer/localbuf.c | 3 +-
src/backend/storage/lmgr/lock.c | 12 ++------
src/backend/storage/lmgr/lwlock.c | 3 +-
src/backend/storage/lmgr/predicate.c | 20 +++++-------
src/backend/storage/smgr/md.c | 3 +-
src/backend/storage/smgr/smgr.c | 3 +-
src/backend/utils/adt/array_typanalyze.c | 3 +-
src/backend/utils/adt/pg_locale.c | 3 +-
src/backend/utils/adt/ri_triggers.c | 9 ++----
src/backend/utils/cache/attoptcache.c | 3 +-
src/backend/utils/cache/evtcache.c | 3 +-
src/backend/utils/cache/relcache.c | 6 ++--
src/backend/utils/cache/relfilenodemap.c | 3 +-
src/backend/utils/cache/spccache.c | 3 +-
src/backend/utils/cache/ts_cache.c | 9 ++----
src/backend/utils/cache/typcache.c | 6 ++--
src/backend/utils/fmgr/fmgr.c | 3 +-
src/backend/utils/hash/dynahash.c | 34 ++++++++++++++++++++-
src/backend/utils/hash/hashfn.c | 8 ++---
src/backend/utils/time/combocid.c | 3 +-
src/include/utils/hsearch.h | 37 ++++++++++++++---------
src/pl/plperl/plperl.c | 6 ++--
src/pl/plpgsql/src/pl_comp.c | 3 +-
src/pl/plpython/plpy_plpymodule.c | 3 +-
src/pl/plpython/plpy_procedure.c | 3 +-
src/pl/tcl/pltcl.c | 6 ++--
42 files changed, 127 insertions(+), 155 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Improve hash_create's API for selecting simple-binary-key hash f
In-Reply-To: <E1Y1fwL-0001Fv-Lw@gemulon.postgresql.org>
References: <E1Y1fwL-0001Fv-Lw@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox