Re: Let's make PostgreSQL multi-threaded - Mailing list pgsql-hackers
From | Tomas Vondra |
---|---|
Subject | Re: Let's make PostgreSQL multi-threaded |
Date | |
Msg-id | 29fe5f48-a6ed-d896-45ed-16b5904353a9@enterprisedb.com Whole thread Raw |
In response to | Re: Let's make PostgreSQL multi-threaded (Heikki Linnakangas <hlinnaka@iki.fi>) |
Responses |
Re: Let's make PostgreSQL multi-threaded
Re: Let's make PostgreSQL multi-threaded |
List | pgsql-hackers |
On 6/5/23 17:33, Heikki Linnakangas wrote: > On 05/06/2023 11:18, Tom Lane wrote: >> Heikki Linnakangas <hlinnaka@iki.fi> writes: >>> I spoke with some folks at PGCon about making PostgreSQL multi-threaded, >>> so that the whole server runs in a single process, with multiple >>> threads. It has been discussed many times in the past, last thread on >>> pgsql-hackers was back in 2017 when Konstantin made some experiments >>> [0]. >> >>> I feel that there is now pretty strong consensus that it would be a good >>> thing, more so than before. Lots of work to get there, and lots of >>> details to be hashed out, but no objections to the idea at a high level. >> >>> The purpose of this email is to make that silent consensus explicit. If >>> you have objections to switching from the current multi-process >>> architecture to a single-process, multi-threaded architecture, please >>> speak up. >> >> For the record, I think this will be a disaster. There is far too much >> code that will get broken, largely silently, and much of it is not >> under our control. > > Noted. Other large projects have gone through this transition. It's not > easy, but it's a lot easier now than it was 10 years ago. The platform > and compiler support is there now, all libraries have thread-safe > interfaces, etc. > Is the platform support really there for all platforms we want/intend to support? I have no problem believing that for modern Linux/BSD systems, but what about the older stuff we currently support. Also, which other projects did this transition? Is there something we could learn from them? Were they restricted to much smaller list of platforms? > I don't expect you or others to buy into any particular code change at > this point, or to contribute time into it. Just to accept that it's a > worthwhile goal. If the implementation turns out to be a disaster, then > it won't be accepted, of course. But I'm optimistic. > I personally am not opposed to the effort in principle, but how do you even evaluate cost and benefits for a transition like this? I have no idea how to quantify the costs/benefits for this as a single change. I've seen some benchmarks in the past, but it's hard to say which of these improvements are possible only with threads, and what would be doable with less invasive changes with the process model. IMHO the only way to move this forward is to divide this into smaller changes, each of which gives us some benefit we'd want anyway. For example, this thread already mentioned improving handling of many connections. AFAICS that requires isolating "session state", which seems useful even without a full switch to threads as it makes connection pooling simpler. It should be easier to get a buy-in for these changes, while introducing abstractions simplifying the switch to threads. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
pgsql-hackers by date: