summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund2014-10-21 15:33:47 +0000
committerAndres Freund2014-10-21 15:33:47 +0000
commit427374b962fc700e9f474ec72635fe907c0853cd (patch)
treea3e044bba9c066741c6c14bdbbd0efc33ed1f893
parentae4b65c39ac5113daada5f44546e09b4c365b11e (diff)
minor chash performance improvementstmp2
-rw-r--r--src/backend/utils/hash/chash.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/utils/hash/chash.c b/src/backend/utils/hash/chash.c
index 0d4dc78a4e..7b289145d1 100644
--- a/src/backend/utils/hash/chash.c
+++ b/src/backend/utils/hash/chash.c
@@ -236,7 +236,7 @@ char *CHashStatisticsNames[] = {
static CHashPtr CHashAllocate(CHashTable table);
static CHashPtr CHashAllocateViaGC(CHashTable table);
static void CHashAddToGarbage(CHashTable table, uint32 bucket, CHashPtr c);
-static void CHashBucketScan(CHashTable table,
+static inline void CHashBucketScan(CHashTable table,
CHashPtr *start,
uint32 hashcode,
const void *key,
@@ -450,7 +450,8 @@ CHashSearch(CHashTable table, void *entry)
/* Prevent garbage collection for this bucket. */
Assert(MyProc->hazard[0] == NULL);
MyProc->hazard[0] = CHashTableGetGarbageByBucket(table, bucket);
- pg_memory_barrier();
+ pg_write_barrier();
+ pg_read_barrier();
/* Scan bucket and return data from any matching entry. */
CHashBucketScan(table, b, hashcode, entry, &scan);
@@ -461,7 +462,8 @@ CHashSearch(CHashTable table, void *entry)
/* Allow garbage collection for this bucket. */
Assert(MyProc->hazard[0] != NULL);
- pg_memory_barrier();
+ pg_write_barrier();
+ pg_read_barrier();
MyProc->hazard[0] = NULL;
CHashTableIncrementStatistic(table, CHS_Search);
@@ -670,7 +672,7 @@ CHashStatistics(CHashTable table, uint64 *stats)
* location in memory. If res->found, then res->next will be the next pointer
* of res->target_node; otherwise, it's undefined.
*/
-static void
+static inline void
CHashBucketScan(CHashTable table,
CHashPtr *start,
uint32 hashcode,
@@ -973,13 +975,13 @@ CHashAllocateViaGC(CHashTable table)
volatile PGPROC *proc = &ProcGlobal->allProcs[i];
void *hazard;
- hazard = proc->hazard[0];
+ hazard = __sync_fetch_and_add(&proc->hazard[0], 0);
if (hazard == b || hazard == fh)
{
CHashTableIncrementStatistic(table, CHS_GC_Spin);
do
{
- hazard = proc->hazard[0];
+ hazard = __sync_fetch_and_add(&proc->hazard[0], 0);
} while (hazard == b || hazard == fh);
}
}