pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: beikov (@beikov) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: Re: [pgjdbc/pgjdbc] PR #4010: [#2325] Execute queries as pipelined when running on virtual thread
Date: Fri, 27 Mar 2026 11:59:49 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
The design is pretty simple. First, the code extracted the queues of the `QueryExecutor` into a wrapper object and passes that to all methods instead of relying on the shared state on the `QueryExecutor`.
That way, a high level operation can isolate all necessary queue objects when multiple threads call into the `QueryExecutor`.
Next, the new `executePipelined` method was introduced that creates isolated queues and splits its work into 3 phases:
1. While holding a write lock, acquire a "ticket" and send operations to the server
2. Lock and wait until it's the turn of the "ticket"
3. Process results
When done, it signals that the next "ticket" can start it's work.
This way, we can send multiple operations to the server in a pipelined fashion, but process results in FIFO order.
With e.g. virtual threads, when a read blocks a VT1, another virtual thread VT2 can send further commands before it enters Phase 2 and waits for its turn. As long as VT1 is waiting, further virtual threads can send even further commands.
Once VT1 is woken up, it needs to process the results and complete before further operations can be sent by other virtual threads.
This means that new operations can only be added while the thread whose turn it is waits for data in Phase 3. To achieve better pipeline usage, we'd need to defer the waking of the thread whose turn it is until all other virtual threads submitted their operations, but I don't know if there is a good way to do that.
Maybe someone has an idea how to achieve better utilization?
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: github://pgjdbc/pgjdbc
Cc: [email protected], [email protected]
Subject: Re: [pgjdbc/pgjdbc] PR #4010: [#2325] Execute queries as pipelined when running on virtual thread
In-Reply-To: <<[email protected]>>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox