Re: Speed up Clog Access by increasing CLOG buffers - Mailing list pgsql-hackers
From | Simon Riggs |
---|---|
Subject | Re: Speed up Clog Access by increasing CLOG buffers |
Date | |
Msg-id | CANP8+jKGcCypXg6cTsAx=vOze81wHrEmEUPu9qWj8BfwvB9Thw@mail.gmail.com Whole thread Raw |
In response to | Re: Speed up Clog Access by increasing CLOG buffers (Amit Kapila <amit.kapila16@gmail.com>) |
Responses |
Re: Speed up Clog Access by increasing CLOG buffers
|
List | pgsql-hackers |
On 17 November 2015 at 06:50, Amit Kapila <amit.kapila16@gmail.com> wrote:
--
In anycase, I went ahead and tried further reducing the CLogControlLockcontention by grouping the transaction status updates. The basic ideais same as is used to reduce the ProcArrayLock contention [1] which is toallow one of the proc to become leader and update the transaction status forother active transactions in system. This has helped to reduce the contentionaround CLOGControlLock.
Sounds good. The technique has proved effective with proc array and makes sense to use here also.
Attached patch group_update_clog_v1.patchimplements this idea.
I don't think we should be doing this only for transactions that don't have subtransactions. We are trying to speed up real cases, not just benchmarks.
So +1 for the concept, patch is going in right direction though lets do the full press-up.
The above data indicates that contention due to CLogControlLock isreduced by around 50% with this patch.
The reasons for remaining contention could be:
1. Readers of clog data (checking transaction status data) can takeExclusive CLOGControlLock when reading the page from disk, this cancontend with other Readers (shared lockers of CLogControlLock) and with
exclusive locker which updates transaction status. One of the ways tomitigate this contention is to increase the number of CLOG buffers for whichpatch has been already posted on this thread.
2. Readers of clog data (checking transaction status data) takes sharedCLOGControlLock which can contend with exclusive locker (Group leader) whichupdates transaction status. I have tried to reduce the amount of work doneby group leader, by allowing group leader to just read the Clog page oncefor all the transactions in the group which updated the same CLOG page(idea similar to what we currently we use for updating the status of transactionshaving sub-transaction tree), but that hasn't given any further performance boost,so I left it.I think we can use some other ways as well to reduce the contention aroundCLOGControlLock by doing somewhat major surgery around SLRU like usingbuffer pools similar to shared buffers, but this idea gives us moderateimprovement without much impact on exiting mechanism.
My earlier patch to reduce contention by changing required lock level is still valid here. Increasing the number of buffers doesn't do enough to remove that.
I'm working on a patch to use a fast-update area like we use for GIN. If a page is not available when we want to record commit, just store it in a hash table, when not in crash recovery. I'm experimenting with writing WAL for any xids earlier than last checkpoint, though we could also trickle writes and/or flush them in batches at checkpoint time - your code would help there.
The hash table can also be used for lookups. My thinking is that most reads of older xids are caused by long running transactions, so they cause a page fault at commit and then other page faults later when people read them back in. The hash table works for both kinds of page fault.
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
pgsql-hackers by date: