Skip to content

Commit e2050fa

Browse files
committed
Imporove sleep statistic reporting
1 parent 5c4cded commit e2050fa

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

pg_dtm.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,21 @@ TransactionId DtmGetOldestXmin(Relation rel, bool ignoreVacuum)
438438

439439
bool DtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
440440
{
441+
#if TRACE_SLEEP_TIME
442+
static timestamp_t firstReportTime;
443+
static timestamp_t prevReportTime;
444+
static timestamp_t totalSleepTime;
445+
#endif
441446
timestamp_t delay = MIN_WAIT_TIMEOUT;
442447
Assert(xid != InvalidTransactionId);
443448

444449
SpinLockAcquire(&local->lock);
445450

451+
#if TRACE_SLEEP_TIME
452+
if (firstReportTime == 0) {
453+
firstReportTime = dtm_get_current_time();
454+
}
455+
#endif
446456
while (true)
447457
{
448458
DtmTransStatus* ts = (DtmTransStatus*)hash_search(xid2status, &xid, HASH_FIND, NULL);
@@ -461,14 +471,11 @@ bool DtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
461471
#if TRACE_SLEEP_TIME
462472
{
463473
timestamp_t now = dtm_get_current_time();
464-
static timestamp_t firstReportTime;
465-
static timestamp_t prevReportTime;
466-
static timestamp_t totalSleepTime;
467474
#endif
468475
dtm_sleep(delay);
469476
#if TRACE_SLEEP_TIME
470477
totalSleepTime += dtm_get_current_time() - now;
471-
if (now > prevReportTime + USEC*10) {
478+
if (now > prevReportTime + USEC*1) {
472479
prevReportTime = now;
473480
if (firstReportTime == 0) {
474481
firstReportTime = now;

tests/deploy/cluster.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
pg_destroy_and_init: true
1212
pg_datadir: ./postgrespro-data
1313
pg_config_role:
14-
- line: "dtm.vacuum_delay=60"
14+
- line: "dtm.vacuum_delay=1000"
1515

1616
tasks:
1717

tests/run.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
./dtmbench \
22
-c "dbname=postgres host=localhost user=knizhnik port=5432 sslmode=disable" \
33
-c "dbname=postgres host=localhost user=knizhnik port=5433 sslmode=disable" \
4-
-c "dbname=postgres host=localhost user=knizhnik port=5434 sslmode=disable" \
5-
-n 1000 -a 1000 -w 10 -r 1 $*
4+
-n 10000 -a 1000 -w 10 -r 1 $*

tests/transfers.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ const (
1818

1919

2020
var cfg1 = pgx.ConnConfig{
21-
Host: "astro9",
22-
Port: 15432,
21+
Host: "127.0.0.1",
22+
Port: 5432,
2323
Database: "postgres",
2424
}
2525

2626
var cfg2 = pgx.ConnConfig{
27-
Host: "astro9",
28-
Port: 15433,
27+
Host: "127.0.0.1",
28+
Port: 5433,
2929
Database: "postgres",
3030
}
3131

@@ -109,8 +109,8 @@ func transfer(id int, wg *sync.WaitGroup) {
109109

110110
gtid := strconv.Itoa(id) + "." + strconv.Itoa(i)
111111
amount := 2*rand.Intn(2) - 1
112-
account1 := 2*id+1
113-
account2 := 2*id+2
112+
account1 := rand.Intn(N_ACCOUNTS)
113+
account2 := rand.Intn(N_ACCOUNTS)
114114

115115
exec(conn1, "begin transaction")
116116
exec(conn2, "begin transaction")

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