On 2/1/18 19:21, Simon Riggs wrote: > If we really can't persuade you of that, it doesn't sink the patch. We > can have the WAL pointer itself - it wouldn't save space but it would > at least alleviate the spinlock.
Do you want to send in an alternative patch that preserves the WAL pointer and only changes the locking?
Sorry for the delay. Here is an updated patch which now replaces xl_prev with xl_curr, thus providing similar safeguards against corrupted or torn WAL pages, but still providing benefits of atomic operations.
I repeated the same set of tests and the results are almost similar. These tests are done on a different AWS instance though and hence not comparable to previous tests. What we do in these tests is essentially call ReserveXLogInsertLocation() 1M times to reserve 256 bytes each time, in a single select statement (the function is exported and a SQL-callable routine is added for the purpose of the tests)
Patched:
======
#clients #tps
134.195311
229.001584
431.712009
835.489272
1641.950044
Master:
======
#clients #tps
124.128004
212.326135
48.334143
816.035699
168.502794
So that's pretty good improvement across the spectrum.