Re: Postgres with pthread - Mailing list pgsql-hackers

From Konstantin Knizhnik
Subject Re: Postgres with pthread
Date
Msg-id 5e757775-630f-5a6a-978a-a240d64259c8@postgrespro.ru
Whole thread Raw
In response to Re: Postgres with pthread  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
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 descriptor cache
or contention for file descriptors?
Right now each thread has its own virtual file descriptors, so them are 
not shared between threads.
But there is common LRU, restricting total number of opened descriptors 
in the process.

Actually I have not other choice if I want to support thousands of 
connection.
If each thread has its own private descriptor cache (as it is now for 
processes) and its size is estimated base on open file quota,
then there will be millions of opened file descriptors.

Concerning contention for mutex, I do not think that it is a problem.
At least I have to say that performance (with 100 connections) is 
significantly improved and shows almost the same speed as for 10 
connections
after I have rewritten file descriptor can and made it global
(my original implementation just made all fd.c static variables as 
thread local, so each thread has its separate pool).

It is possible to go further and shared file descriptors between threads 
and use pwrite/pread instead of seek+read/write.
But we still need mutex to implement LRU l2list and free handler list.


pgsql-hackers by date:

Previous
From: Konstantin Knizhnik
Date:
Subject: Re: Postgres with pthread
Next
From: Konstantin Knizhnik
Date:
Subject: Re: Postgres with pthread