From: | Потапов Александр <a(dot)potapov(at)postgrespro(dot)ru> |
---|---|
To: | "Matthias van de Meent" <boekewurm+postgres(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Init connection time grows quadratically |
Date: | 2025-06-10 08:56:58 |
Message-ID: | 2ab4be-6847f380-11-1d048f40@125133490 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Matthias,
I did additional experiments (changed a number of threads on pgbench side an on server side) but it did find not chanches.
Вторник, Май 27, 2025 14:36 MSK, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com> писал(а):
On Tue, 27 May 2025 at 12:45, Потапов Александр
<a(dot)potapov(at)postgrespro(dot)ru> wrote:
>
> Hello!
>
> I ran some experiments with pgbench to measure the initialization time and found that the time increases quadratically with the number of clients. It was surprising to me and I would like to understand a reason of such behavior.
>
> Some details on how it was done:
>
[...]
>
> It turned out that the results correspond to a quadratic dependence like y ~ 0.0002x^2 where x is a number of clients and y is init time (ms).
> Here there is a question: is it expected behavior or a bug? What do you think? I appreciate any comments and opinions.
Note that the value of "initial connection time" is based on the time
it takes from about the start of the pg_bench process until the moment
all N expected connections have been established, *not* the average
time it took pg_bench to connect to PostgreSQL. This does also not
exclude other known measurable delays (like spawning threads,
synchronization, etc), so the actual per-connection connection time is
probably closer to O(n) than O(n^2).
Q: Did you check that pgbench or the OS does not have
O(n_active_connections) or O(n_active_threads) overhead per worker
during thread creation or connection establishment, e.g. by varying
the number of threads used to manage these N clients? I wouldn't be
surprised if there are inefficiencies in e.g. the threading- or
synchronization model that cause O(N) per-thread overhead, or O(N^2)
overall when you have one thread per connection.
Kind regards,
Matthias van de Meent
Neon (https://neon.tech)
From | Date | Subject | |
---|---|---|---|
Next Message | shveta malik | 2025-06-10 08:59:13 | Re: Fix slot synchronization with two_phase decoding enabled |
Previous Message | Steve Senior | 2025-06-10 08:24:14 | User timeouts for scheduling functions |