Skip to content

Configurable recycler for pooled sessions - #1383

Open
sideeffffect wants to merge 2 commits into
typelevel:mainfrom
sideeffffect:configurable-pool-recycler
Open

sideeffffect wants to merge 2 commits into
typelevel:mainfrom
sideeffffect:configurable-pool-recycler

Conversation

@sideeffffect

@sideeffffect sideeffffect commented Oct 29, 2026 •

Copy link
Copy Markdown

Makes recycler configurable. Allows for avoiding UNLISTEN * and RESET ALL to make it more performant.

sideeffffect and others added 2 commits October 30, 2026 00:32
Add `Session.Builder#withRecycler` to choose the recycler run on each
session returned to the pool. The default stays `Recyclers.full`.

Add `Recyclers.idle`, which only checks that the session is healthy and
idle (no open or failed transaction) and closes evicted prepared
statements. It does not run `UNLISTEN *` and `RESET ALL`, so it saves
two statements per checkout.

Closes typelevel#877

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JMH benchmark of a pooled session (pool of 1) with the full and the
idle recycler: checkout+checkin alone, and checkout + one warm
parameterized query + checkin. Needs the docker-compose Postgres.

Results, `bench/Jmh/run -i 10 PoolRecyclerBench` (1 fork, 5x5s warmup,
10x5s measurement), local Postgres 11 in Docker, JDK 21, load average
3 to 4, ops/s:

| Benchmark            | full          | idle            | change |
|----------------------|---------------|-----------------|--------|
| checkoutCheckin      | 10108 +- 162  | 109446 +- 6865  | 10.8x  |
| checkoutQueryCheckin |  5283 +- 116  |  10479 +- 293   |  2.0x  |

An earlier 5-iteration run gave the same picture for the query case
(5259 vs 10487). Its full checkoutCheckin result was noisy
(5721 +- 3444), with load average 23 at the start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sideeffffect
sideeffffect marked this pull request as ready for review October 30, 2026 16:29

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant