Re: Postgres with pthread

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Postgres with pthread
Date: 2017-12-07 12:06:43
Message-ID: 5e757775-630f-5a6a-978a-a240d64259c8@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Konstantin Knizhnik 2017-12-07 12:13:52 Re: Postgres with pthread
Previous Message Konstantin Knizhnik 2017-12-07 11:55:29 Re: Postgres with pthread