slow startup due to LWLockAssign() spinlock - Mailing list pgsql-hackers

From Andres Freund
Subject slow startup due to LWLockAssign() spinlock
Date
Msg-id 20140202164303.GQ5930@awork2.anarazel.de
Whole thread Raw
Responses Re: slow startup due to LWLockAssign() spinlock  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

On larger, multi-socket, machines, startup takes a fair bit of time. As
I was profiling anyway I looked into it and noticed that just about all
of it is spent in LWLockAssign() called by InitBufferPool(). Starting
with shared_buffers=48GB on the server Nate Boley provided, takes about
12 seconds. Nearly all of it spent taking the ShmemLock spinlock.
Simply modifying LWLockAssign() to not take the spinlock when
!IsUnderPostmaster speeds it up to 2 seconds. While certainly not making
LWLockAssign() prettier it seems enough of a speedup to be worthwile
nonetheless.
Since this code is also hit when do an emergency restart, I'd say it has
practical relevance...

Greetings,

Andres Freund

--
 Andres Freund                       http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: mvcc catalo gsnapshots and TopTransactionContext
Next
From: Greg Stark
Date:
Subject: Re: Recovery inconsistencies, standby much larger than primary