Re: Postgres with pthread

2017-12-27 Thread Konstantin Knizhnik
On 27.12.2017 13:08, Andres Freund wrote: On December 27, 2017 11:05:52 AM GMT+01:00, james wrote: All threads are blocked in semaphores. That they are blocked is inevitable - I guess the issue is that they are thrashing. I guess it would be necessary to separate the internals to have some

Re: Postgres with pthread

2017-12-27 Thread james
On 27/12/2017 10:08, Andres Freund wrote: Optimizing for this seems like a pointless exercise. If the goal is efficient processing of 100k connections the solution is a session / connection abstraction and a scheduler. Optimizing for this amount of concurrency just will add complexity and sl

Re: Postgres with pthread

2017-12-27 Thread Andres Freund
On December 27, 2017 11:05:52 AM GMT+01:00, james wrote: > > All threads are blocked in semaphores. >That they are blocked is inevitable - I guess the issue is that they >are >thrashing. >I guess it would be necessary to separate the internals to have some >internal queueing and effectively r

Re: Postgres with pthread

2017-12-27 Thread james
> All threads are blocked in semaphores. That they are blocked is inevitable - I guess the issue is that they are thrashing. I guess it would be necessary to separate the internals to have some internal queueing and effectively reduce the number of actively executing threads. In effect make th

Re: Postgres with pthread

2017-12-27 Thread Konstantin Knizhnik
far from completion. 4. I have performed experiments with replacing synchronization primitives used in Postgres with pthread analogues. Unfortunately it has almost now influence on performance. 5. Handling large number of connections. The maximal number of postgres connections is almost the

Re: Postgres with pthread

2017-12-21 Thread Pavel Stehule
l regression tests now. But handling of > errors is still far from completion. > > 4. I have performed experiments with replacing synchronization primitives > used in Postgres with pthread analogues. > Unfortunately it has almost now influence on performance. > > 5. Handling l

Re: Postgres with pthread

2017-12-21 Thread Konstantin Knizhnik
experiments with replacing synchronization primitives used in Postgres with pthread analogues. Unfortunately it has almost now influence on performance. 5. Handling large number of connections. The maximal number of postgres connections is almost the same: 100k. But memory footprint in case of pthreads

Re: Postgres with pthread

2017-12-10 Thread james
On 06/12/2017 17:26, Andreas Karlsson wrote: An additional issue is that this could break a lot of extensions and in a way that it is not apparent at compile time. This means we may need to break all extensions to force extensions authors to check if they are thread safe. I do not like making

Re: Postgres with pthread

2017-12-08 Thread Alexander Korotkov
On Sat, Dec 9, 2017 at 1:09 AM, konstantin knizhnik < k.knizh...@postgrespro.ru> wrote: > I am not going to show stack traces of all 1000 threads. > But you may notice that proc array lock really seems be be a bottleneck. > Yes, proc array lock easily becomes a bottleneck on multicore machine wit

Re: Postgres with pthread

2017-12-08 Thread konstantin knizhnik
On Dec 7, 2017, at 10:41 AM, Simon Riggs wrote: >> But it is a theory. The main idea of this prototype was to prove or disprove >> this expectation at practice. > >> But please notice that it is very raw prototype. A lot of stuff is not >> working yet. > >> And supporting all of exited Postgres

Re: Postgres with pthread

2017-12-07 Thread Craig Ringer
On 8 December 2017 at 03:58, Andres Freund wrote: > On 2017-12-07 11:26:07 +0800, Craig Ringer wrote: > > PostgreSQL's architecture conflates "connection", "session" and > "executor" > > into one somewhat muddled mess. > > How is the executor entangled in the other two? > > Executor in the postgr

Re: Postgres with pthread

2017-12-07 Thread Andres Freund
Hi, On 2017-12-07 20:48:06 +, Greg Stark wrote: > But then I thought about it a bit and I do wonder. I don't know how > well we test having multiple portals doing all kinds of different > query plans with their execution interleaved. Cursors test that pretty well. > And I definitely have do

Re: Postgres with pthread

2017-12-07 Thread Greg Stark
On 7 December 2017 at 19:58, Andres Freund wrote: > On 2017-12-07 11:26:07 +0800, Craig Ringer wrote: >> PostgreSQL's architecture conflates "connection", "session" and "executor" >> into one somewhat muddled mess. > > How is the executor entangled in the other two? I was going to ask the same qu

Re: Postgres with pthread

2017-12-07 Thread Andres Freund
On 2017-12-07 11:26:07 +0800, Craig Ringer wrote: > PostgreSQL's architecture conflates "connection", "session" and "executor" > into one somewhat muddled mess. How is the executor entangled in the other two? Greetings, Andres Freund

Re: Postgres with pthread

2017-12-07 Thread Robert Haas
On Wed, Dec 6, 2017 at 10:20 PM, Craig Ringer wrote: > Personally I think it's a pity we didn't land up here before the foundations > for parallel query went in - DSM, shm_mq, DSA, etc. I know the EDB folks at > least looked into it though, and presumably there were good reasons to go in > this di

Re: Postgres with pthread

2017-12-07 Thread Craig Ringer
On 7 December 2017 at 19:55, Konstantin Knizhnik wrote: > > Pros: > 1. Simplified memory model: no need in DSM, shm_mq, DSA, etc > shm_mq would remain useful, and the others could only be dropped if you also dropped process-model support entirely. > 1. Breaks compatibility with existed extensi

Re: Postgres with pthread

2017-12-07 Thread Konstantin Knizhnik
On 07.12.2017 00:58, Thomas Munro wrote: Using a ton of thread local variables may be a useful stepping stone, but if we want to be able to separate threads/processes from sessions eventually then I guess we'll want to model sessions as first class objects and pass them around explicitly or usi

Re: Postgres with pthread

2017-12-07 Thread Konstantin Knizhnik
Hi On 06.12.2017 20:08, Andres Freund wrote: 4. Rewrite file descriptor cache to be global (shared by all threads). That one I'm very unconvinced of, that's going to add a ton of new contention. Do you mean lock contention because of mutex I used to synchronize access to shared file descript

Re: Postgres with pthread

2017-12-07 Thread Konstantin Knizhnik
I want to thank everybody for feedbacks and a lot of useful notices. I am very pleased with interest of community to this topic and will continue research in this direction. Some more comments from my side: My original intention was to implement some king of built-in connection pooling for Pos

Re: Postgres with pthread

2017-12-06 Thread Simon Riggs
> But it is a theory. The main idea of this prototype was to prove or disprove > this expectation at practice. > But please notice that it is very raw prototype. A lot of stuff is not > working yet. > And supporting all of exited Postgres functionality requires > much more efforts (and even more

Re: Postgres with pthread

2017-12-06 Thread Craig Ringer
On 7 December 2017 at 11:44, Tsunakawa, Takayuki < tsunakawa.ta...@jp.fujitsu.com> wrote: > From: Craig Ringer [mailto:cr...@2ndquadrant.com] > > I'd personally expect that an immediate conversion would result > > in very > > little speedup, a bunch of code deleted, a bunch of complexi

RE: Postgres with pthread

2017-12-06 Thread Tsunakawa, Takayuki
From: Craig Ringer [mailto:cr...@2ndquadrant.com] > I'd personally expect that an immediate conversion would result > in very > little speedup, a bunch of code deleted, a bunch of complexity > added. And it'd still be massively worthwhile, to keep medium to > long > term com

Re: Postgres with pthread

2017-12-06 Thread Craig Ringer
On 7 December 2017 at 05:58, Thomas Munro wrote: > > Using a ton of thread local variables may be a useful stepping stone, > but if we want to be able to separate threads/processes from sessions > eventually then I guess we'll want to model sessions as first class > objects and pass them around e

Re: Postgres with pthread

2017-12-06 Thread Craig Ringer
On 7 December 2017 at 01:17, Andres Freund wrote: > > > I think you've done us a very substantial service by pursuing > > this far enough to get some quantifiable performance results. > > But now that we have some results in hand, I think we're best > > off sticking with the architecture we've g

Re: Postgres with pthread

2017-12-06 Thread Thomas Munro
On Thu, Dec 7, 2017 at 6:08 AM, Andres Freund wrote: > On 2017-12-06 19:40:00 +0300, Konstantin Knizhnik wrote: >> As far as I remember, several years ago when implementation of intra-query >> parallelism was just started there was discussion whether to use threads or >> leave traditional Postgres

Re: Postgres with pthread

2017-12-06 Thread Andres Freund
Hi, On 2017-12-06 12:28:29 -0500, Robert Haas wrote: > > Possibly we even want to continue having various > > processes around besides that, the most interesting cases involving > > threads are around intra-query parallelism, and pooling, and for both a > > hybrid model could be beneficial. > > I

Re: Postgres with pthread

2017-12-06 Thread Robert Haas
On Wed, Dec 6, 2017 at 12:08 PM, Andres Freund wrote: >> 4. Rewrite file descriptor cache to be global (shared by all threads). > > That one I'm very unconvinced of, that's going to add a ton of new > contention. It might be OK on systems where we can use pread()/pwrite(). Otherwise it's going to

Re: Postgres with pthread

2017-12-06 Thread Andreas Karlsson
On 12/06/2017 06:08 PM, Andres Freund wrote: I think the biggest problem with doing this for real is that it's a huge project, and that it'll take a long time. An additional issue is that this could break a lot of extensions and in a way that it is not apparent at compile time. This means we m

Re: Postgres with pthread

2017-12-06 Thread Adam Brusselback
> "barely a 50% speedup" - Hah. I don't believe the numbers, but that'd be > huge. They are numbers derived from a benchmark that any sane person would be using a connection pool for in a production environment, but impressive if true none the less.

Re: Postgres with pthread

2017-12-06 Thread Andres Freund
Hi, On 2017-12-06 11:53:21 -0500, Tom Lane wrote: > Konstantin Knizhnik writes: > However, if I guess at which numbers are supposed to be what, > it looks like even the best case is barely a 50% speedup. "barely a 50% speedup" - Hah. I don't believe the numbers, but that'd be huge. > That woul

Re: Postgres with pthread

2017-12-06 Thread Robert Haas
On Wed, Dec 6, 2017 at 11:53 AM, Tom Lane wrote: > barely a 50% speedup. I think that's an awfully strange choice of adverb. This is, by its authors own admission, a rough cut at this, probably with very little of the optimization that could ultimately done, and it's already buying 50% on some t

Re: Postgres with pthread

2017-12-06 Thread Andres Freund
Hi! On 2017-12-06 19:40:00 +0300, Konstantin Knizhnik wrote: > As far as I remember, several years ago when implementation of intra-query > parallelism was just started there was discussion whether to use threads or > leave traditional Postgres process architecture. The decision was made to > leav

Re: Postgres with pthread

2017-12-06 Thread Adam Brusselback
Here it is formatted a little better. ​ So a little over 50% performance improvement for a couple of the test cases. On Wed, Dec 6, 2017 at 11:53 AM, Tom Lane wrote: > Konstantin Knizhnik writes: > > Below are some results (1000xTPS) of select-only (-S) pgbench with scale > > 100 at my des

Re: Postgres with pthread

2017-12-06 Thread Tom Lane
Konstantin Knizhnik writes: > Below are some results (1000xTPS) of select-only (-S) pgbench with scale > 100 at my desktop with quad-core i7-4770 3.40GHz and 16Gb of RAM: > Connections    Vanilla/default   Vanilla/prepared > pthreads/defaultpthreads/prepared > 10                    100 191 

Postgres with pthread

2017-12-06 Thread Konstantin Knizhnik
Hi hackers, As far as I remember, several years ago when implementation of intra-query parallelism was just started there was discussion whether to use threads or leave traditional Postgres process architecture. The decision was made to leave processes. So now we have bgworkers, shared messag