postgresql/src/include/utils
Andres Freund 141fd1b66c Improve sys/catcache performance.
The following are the individual improvements:
1) Avoidance of FunctionCallInfo based function calls, replaced by
   more efficient functions with a native C argument interface.
2) Don't extract columns from a cache entry's tuple whenever matching
   entries - instead store them as a Datum array. This also allows to
   get rid of having to build dummy tuples for negative & list
   entries, and of a hack for dealing with cstring vs. text weirdness.
3) Reorder members of catcache.h struct, so imortant entries are more
   likely to be on one cacheline.
4) Allowing the compiler to specialize critical SearchCatCache for a
   specific number of attributes allows to unroll loops and avoid
   other nkeys dependant initialization.
5) Only initializing the ScanKey when necessary, i.e. catcache misses,
   greatly reduces cache unnecessary cpu cache misses.
6) Split of the cache-miss case from the hash lookup, reducing stack
   allocations etc in the common case.
7) CatCTup and their corresponding heaptuple are allocated in one
   piece.

This results in making cache lookups themselves roughly three times as
fast - full-system benchmarks obviously improve less than that.

I've also evaluated further techniques:
- replace open coded hash with simplehash - the list walk right now
  shows up in profiles. Unfortunately it's not easy to do so safely as
  an entry's memory location can change at various times, which
  doesn't work well with the refcounting and cache invalidation.
- Cacheline-aligning CatCTup entries - helps some with performance,
  but the win isn't big and the code for it is ugly, because the
  tuples have to be freed as well.
- add more proper functions, rather than macros for
  SearchSysCacheCopyN etc., but right now they don't show up in
  profiles.

The reason the macro wrapper for syscache.c/h have to be changed,
rather than just catcache, is that doing otherwise would require
exposing the SysCache array to the outside.  That might be a good idea
anyway, but it's for another day.

Author: Andres Freund
Reviewed-By: Robert Haas
Discussion: https://postgr.es/m/20170914061207.zxotvyopetm7lrrp@alap3.anarazel.de
2017-10-13 14:22:41 -07:00
..
.gitignore Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
acl.h Fix ordering in pg_dump of GRANTs 2017-09-13 20:02:09 -04:00
aclchk_internal.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
array.h Support arrays over domains. 2017-09-30 13:40:56 -04:00
arrayaccess.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
ascii.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
attoptcache.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
backend_random.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
builtins.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
bytea.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
cash.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
catcache.h Improve sys/catcache performance. 2017-10-13 14:22:41 -07:00
combocid.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
date.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
datetime.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
datum.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
dsa.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
dynahash.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
dynamic_loader.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
elog.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
evtcache.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
expandeddatum.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
fmgrtab.h Msvc doesn't know UINT16_MAX, replace with PG_UINT16_MAX. 2017-10-04 10:01:02 -07:00
formatting.h Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
freepage.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
geo_decls.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
guc_tables.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
guc.h Introduce BYTES unit for GUCs. 2017-09-12 12:13:12 -07:00
hashutils.h Fix typo. 2017-09-29 17:24:39 -07:00
help_config.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
hsearch.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
index_selfuncs.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
inet.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
int8.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
inval.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
json.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
jsonapi.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
jsonb.h Make DatumGetFoo/PG_GETARG_FOO/PG_RETURN_FOO macro names more consistent. 2017-09-18 15:21:23 -04:00
logtape.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
lsyscache.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
memdebug.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
memutils.h Ensure SIZE_MAX can be used throughout our code. 2017-09-01 13:52:53 -04:00
nabstime.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
numeric.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
palloc.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pg_crc.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pg_locale.h Assume wcstombs(), towlower(), and sibling functions are always present. 2017-09-22 11:00:58 -04:00
pg_lsn.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pg_rusage.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pidfile.h Change pg_ctl to detect server-ready by watching status in postmaster.pid. 2017-06-28 17:31:32 -04:00
plancache.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
portal.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
ps_status.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
queryenvironment.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
rangetypes.h Make DatumGetFoo/PG_GETARG_FOO/PG_RETURN_FOO macro names more consistent. 2017-09-18 15:21:23 -04:00
regproc.h Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
rel.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
relcache.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
relfilenodemap.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
relmapper.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
relptr.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
reltrigger.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
resowner_private.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
resowner.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
rls.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
ruleutils.h Improve the error message when creating an empty range partition. 2017-08-10 13:46:56 -04:00
sampling.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
selfuncs.h Reduce excessive dereferencing of function pointers 2017-09-07 13:56:09 -04:00
snapmgr.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
snapshot.h Improve performance of get_actual_variable_range with recently-dead tuples. 2017-09-07 19:41:51 -04:00
sortsupport.h Reduce excessive dereferencing of function pointers 2017-09-07 13:56:09 -04:00
spccache.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
syscache.h Improve sys/catcache performance. 2017-10-13 14:22:41 -07:00
timeout.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
timestamp.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
tqual.h Fix low-probability loss of NOTIFY messages due to XID wraparound. 2017-10-11 14:28:33 -04:00
tuplesort.h Propagate sort instrumentation from workers back to leader. 2017-08-29 13:26:33 -04:00
tuplestore.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
typcache.h Add support for coordinating record typmods among parallel workers. 2017-09-14 19:59:21 -07:00
tzparser.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
uuid.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
varbit.h Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
varlena.h Post-PG 10 beta1 pgindent run 2017-05-17 16:31:56 -04:00
xml.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00