[GSOC] Eliminate O(N^2) scaling from rw-conflict tracking in serializable transactions

From: "Mengxing Liu" <liu-mx15(at)mails(dot)tsinghua(dot)edu(dot)cn>
To: "Alvaro Herrera" <alvherre(at)2ndquadrant(dot)com>, kgrittn <kgrittn(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: [GSOC] Eliminate O(N^2) scaling from rw-conflict tracking in serializable transactions
Date: 2017-07-26 15:41:37
Message-ID: 48d8f6d9.aa9.15d7f8f8260.Coremail.liu-mx15@mails.tsinghua.edu.cn
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, all. There was a very strange phenomenon I couldn't explain. So I was wondering if you can help me.

I was trying to replace the linked list with a skip list in serializable transaction object for faster conflict tracking. But the performance is bad.
So I used the instruction "rdtsc" to compare the speed of my skip list and the original linked list. The skip list was about 1.5x faster.

The interesting thing is that if I added the instruction "rdstc" at the end of the function "RWConflictExists",
the performance of the whole system was increased by at most 3 times!
Here is the result.

| benchmarks | without rdtsc | with rdtsc |
| simpe read/write | 4.91 | 14.16 |
| ssibench | 9.72 | 10.24 |
| tpcb | 26.45 | 26.38 |

( The simple read/write benchmark has the most number of conflicts. )

The patch is attached. All the difference of the two columns is with/without a simple line of code:
__asm__ __volatile__ ("rdtsc");
But I don't know why this instruction will influence the performance so much!

BTW, after adding the "rdtsc" instruction, the performance is better than the original version about 10% at most.
That means, the skip list can work!

Looking forward to your advices.

--
Sincerely

Mengxing Liu

Attachment Content-Type Size
skip-list-for-conflict-tracking.patch application/octet-stream 11.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2017-07-26 15:44:13 Re: Remove old comments in dependencies.c and README.dependencies
Previous Message Tom Lane 2017-07-26 15:35:55 Re: Change in "policy" on dump ordering?