Optimization: Change clean-up of pooled connections to be conditional#46
Optimization: Change clean-up of pooled connections to be conditional#46jduo wants to merge 2 commits intovalkey-io:mainfrom
Conversation
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>
9f326a1 to
52d927e
Compare
|
When running the performance test locally, this roughly doubled the ops/second |
...java/io/valkey/springframework/data/valkey/connection/valkeyglide/ValkeyGlideConnection.java
Outdated
Show resolved
Hide resolved
Signed-off-by: James Duong <duong.james@gmail.com>
|
There is a reason i did it this way - to be on the safe side
I will be looking into this a bit more - if there could be situations in which WATCH is issued w/o updated the watchedKeys |
|
For reference these are the numbers I got running the benchmark and valkey-server on my local machine before/after this patch (ops/s):
|
|
An alternative way to implement this if we want to be extra cautious:
This would have the effect of issuing the cleanup on a background thread and not blocking the app thread from continuing operations. The app thread might need to create a new connection the for the first few operations because it wouldn't finish cleaning them up by the time they are needed again, but after a few are in the pool they should be readily reusable. |
Demo of this path in #46. |
Only send UNWATCH requests when returning a connection to the pool if there have actually been watched keys.
This increases the performance by avoiding a network roundtrip when executing a non-batched operation (for scalar operations this halves the number of roundtrips).