Re: [HACKERS] Proposal for CSN based snapshots

From: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
To: Alexander Kuzmenkov <a(dot)kuzmenkov(at)postgrespro(dot)ru>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Andres Freund <andres(at)anarazel(dot)de>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Greg Stark <stark(at)mit(dot)edu>, Andres Freund <andres(at)2ndquadrant(dot)com>, Rajeev rastogi <rajeev(dot)rastogi(at)huawei(dot)com>, Markus Wanner <markus(at)bluegap(dot)ch>, Ants Aasma <ants(at)cybertec(dot)at>, Bruce Momjian <bruce(at)momjian(dot)us>, obartunov <obartunov(at)postgrespro(dot)ru>, Teodor Sigaev <teodor(at)postgrespro(dot)ru>, Borodin Vladimir <root(at)simply(dot)name>
Subject: Re: [HACKERS] Proposal for CSN based snapshots
Date: 2017-12-08 11:59:42
Message-ID: CAPpHfdtdsvmHQ7Nt2cRNk+BxQ_aY_y_TqTJ=npCP8fFLzBadHw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Dec 4, 2017 at 6:07 PM, Alexander Kuzmenkov <
a(dot)kuzmenkov(at)postgrespro(dot)ru> wrote:

> Performance on pgbench tpcb with subtransactions is now slightly better
> than master. See the picture 'savepoints2'. This was achieved by removing
> unnecessary exclusive locking on CSNLogControlLock in SubTransSetParent.
> After that change, both versions are mostly waiting on XidGenLock in
> GetNewTransactionId.
>
> Performance on default pgbench tpcb is also improved. At scale 500, csn is
> at best 30% faster than master, see the picture 'tpcb500'. These
> improvements are due to slight optimizations of GetSnapshotData and
> refreshing RecentGlobalXmin less often. At scale 1500, csn is slightly
> faster at up to 200 clients, but then degrades steadily: see the picture
> 'tpcb1500'. Nevertheless, CSN-related code paths do not show up in perf
> profiles or LWLock wait statistics [1]. I think what we are seeing here is
> again that when some bottlenecks are removed, the fast degradation of
> LWLocks under contention leads to net drop in performance. With this in
> mind, I tried running the same benchmarks with patch from Yura Sokolov [2],
> which should improve LWLock performance on NUMA machines. Indeed, with this
> patch csn starts outperforming master on all numbers of clients measured,
> as you can see in the picture 'tpcb1500'. This LWLock change influences the
> csn a lot more than master, which also suggests that we are observing a
> superlinear degradation of LWLocks under increasing contention.
>

These results look promising for me. Could you try benchmarking using more
workloads including read-only and mixed mostly-read workloads?
You can try same benchmarks I used in my talk about CSN in pgconf.eu [1]
slides 19-25 (and you're welcome to invent more benchmakrs yourself)

Also, I wonder how current version of CSN patch behaves in worst case when
we have to scan the table with a lot of unique xid (and correspondingly
have to do a lot of csnlog lookups)? See [1] slide 18. This worst case
was significant part of my motivation to try "rewrite xid with csn"
approach. Please, find simple extension I used to fill table with random
xmins in the attachment.

1. https://www.slideshare.net/AlexanderKorotkov/the-future-is-csn

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachment Content-Type Size
randomize_xmin.tar.gz application/x-gzip 1.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2017-12-08 12:42:06 Re: [HACKERS] [PATCH] Incremental sort
Previous Message Alexander Korotkov 2017-12-08 11:50:20 Re: Fwd: [BUGS] pg_trgm word_similarity inconsistencies or bug