Skip to content

Commit 6810e26

Browse files
committed
Some experimates with multimaster performance
1 parent 151af9e commit 6810e26

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

contrib/multimaster/bgwpool.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ typedef struct
1616
int id;
1717
} BgwPoolExecutorCtx;
1818

19+
size_t n_snapshots;
20+
size_t n_active;
21+
1922
static void BgwPoolMainLoop(Datum arg)
2023
{
2124
BgwPoolExecutorCtx* ctx = (BgwPoolExecutorCtx*)arg;
@@ -35,6 +38,7 @@ static void BgwPoolMainLoop(Datum arg)
3538
size = *(int*)&pool->queue[pool->head];
3639
Assert(size < pool->size);
3740
work = palloc(size);
41+
pool->active -= 1;
3842
if (pool->head + size + 4 > pool->size) {
3943
memcpy(work, pool->queue, size);
4044
pool->head = INTALIGN(size);
@@ -68,6 +72,7 @@ void BgwPoolInit(BgwPool* pool, BgwPoolExecutor executor, char const* dbname, si
6872
pool->head = 0;
6973
pool->tail = 0;
7074
pool->size = queueSize;
75+
pool->active = 0;
7176
strcpy(pool->dbname, dbname);
7277
}
7378

@@ -106,6 +111,9 @@ void BgwPoolExecute(BgwPool* pool, void* work, size_t size)
106111
PGSemaphoreLock(&pool->overflow);
107112
SpinLockAcquire(&pool->lock);
108113
} else {
114+
pool->active += 1;
115+
n_snapshots += 1;
116+
n_active += pool->active;
109117
*(int*)&pool->queue[pool->tail] = size;
110118
if (pool->size - pool->tail >= size + 4) {
111119
memcpy(&pool->queue[pool->tail+4], work, size);

contrib/multimaster/bgwpool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ typedef struct
1818
size_t head;
1919
size_t tail;
2020
size_t size;
21+
size_t active;
2122
bool producerBlocked;
2223
char dbname[MAX_DBNAME_LEN];
2324
char* queue;

contrib/multimaster/multimaster.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include "bytebuf.h"
55

66
#define XTM_TRACE(fmt, ...)
7-
#define XTM_INFO(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
8-
//#define XTM_INFO(fmt, ...)
7+
//#define XTM_INFO(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
8+
#define XTM_INFO(fmt, ...)
99

1010
extern int MMStartReceivers(char* nodes, int node_id);
1111
extern void MMBeginTransaction(void);

contrib/multimaster/receiver_raw.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ receiver_raw_main(Datum main_arg)
269269
WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
270270
receiver_idle_time * 1L);
271271
ResetLatch(&MyProc->procLatch);
272-
273272
/* Process signals */
274273
if (got_sighup)
275274
{

contrib/multimaster/tests/dtmbench

6.17 KB
Binary file not shown.

contrib/multimaster/tests/dtmbench.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,9 @@ int main (int argc, char* argv[])
200200
"\t-r N\tnumber of readers (1)\n"
201201
"\t-w N\tnumber of writers (10)\n"
202202
"\t-a N\tnumber of accounts (100000)\n"
203-
"\t-s N\tperform updates starting from this id (1)\n"
204-
"\t-d N\tperform updates in this diapason (100000)\n"
205203
"\t-n N\tnumber of iterations (1000)\n"
206204
"\t-c STR\tdatabase connection string\n"
207-
"\t-i\tinitialize datanase\n");
205+
"\t-i\tinitialize database\n");
208206
return 1;
209207
}
210208

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy