Skip to content

Comments

Optimization: Async cleanup of connections before pooling#48

Draft
jduo wants to merge 4 commits intovalkey-io:mainfrom
jduo:async-cleanup
Draft

Optimization: Async cleanup of connections before pooling#48
jduo wants to merge 4 commits intovalkey-io:mainfrom
jduo:async-cleanup

Conversation

@jduo
Copy link

@jduo jduo commented Jan 16, 2026

Rework the connection state clean-up to happen asynchronously instead of blocking the application thread.
This provides similar performance benefits to skipping the UNWATCH entirely, but is safer due to not
changing the semantics and also more applicable to scenarios where there actually are WATCHed keys.

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

jduo added 3 commits January 14, 2026 11:08
Only send UNWATCH requests when returning a connection to the pool if there have
actually been watched keys.

Signed-off-by: James Duong <duong.james@gmail.com>
Signed-off-by: James Duong <duong.james@gmail.com>
Always issue UNWATCH requests before submitting a connection back to the pool for
reuse, but asynchronously wait for the request to complete instead of blocking
the application thread.

Also cleanup some of the type to use BaseClient instead of Object.

Signed-off-by: James Duong <duong.james@gmail.com>
@jduo
Copy link
Author

jduo commented Jan 16, 2026

This yielded about a 1.75x performance improvement compared to the un-optimized version when testing with the benchmark and server running locally.

It would yield a greater benefit if real network is involved since this lets us do work while a network roundtrip is happening rather than just waiting.

Signed-off-by: James Duong <duong.james@gmail.com>
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