Skip site navigation (1) Skip section navigation (2)

spinlock->pthread_mutex : real world results

From: Nils Goroll <slink(at)schokola(dot)de>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, Merlin Moncure <mmoncure(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: spinlock->pthread_mutex : real world results
Date: 2012-08-05 23:19:27
Message-ID: 501EFF7F.9000400@schokola.de (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi,

meanwhile we're using the patch in production (again, this is 9.1.3) and after 
running it under full load for one week I believe it is pretty safe to say that 
replacing the spinlock code with pthread_mutexes on Linux (which basically are a 
futex wrapper) has solved the scalability issue and all stability/performance 
problems on this system are simply gone.

While the improved pgbench run had already given a clear indication regarding 
the optimization potential, we can now be pretty certain that spinlock 
contention had really been the most significant root cause for the issues I had 
described in my early postings ("why roll-your-own s_lock? / improving 
scalability" / "experimental: replace s_lock spinlock code with pthread_mutex on 
linux").

I am attaching annotated graphs showing the load averages and cpu statistics of 
the respective machine. Please note the fact that the highest spikes have been 
averaged out in these graphs. As I had mentioned before, with the original code 
in place we had seen saturation of 64 cores and load averages in excess of 300.


I fully agree that improvements in more recent pgsql code to reduce the number 
of required locks or, even better, lockless data structures are the way to go, 
but for the remaining cases it should now have become apparent that favoring 
efficient mutex implementations is advantageous for large SMPs, where they exist 
(e.g. futexes on Linux).

Thanks, Nils

Attachment: noslock_realworld_load_2.png
Description: image/png (123.3 KB)
Attachment: noslock_realworld_usr_sys_2.png
Description: image/png (114.6 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2012-08-05 23:52:56
Subject: Re: WIP patch for LATERAL subqueries
Previous:From: Andrew DunstanDate: 2012-08-05 22:58:42
Subject: Re: WIP patch for LATERAL subqueries

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group