deadpool icon indicating copy to clipboard operation
deadpool copied to clipboard

Ahead of time object creation/recycling

Open bikeshedder opened this issue 2 years ago • 3 comments

It would be nice if objects could be created and/or recycled ahead of time. I don't plan on making this feature mandatory but rather add some additional methods that can be used by 3rd party code to modify the pool state.

This future should be opt-in and not enabled by default as highly contested pools with large loads already perform exceptionally well. See https://github.com/bikeshedder/async-pool-benchmark

I would like the code that performs the ahead of time creation/recycling to work with public exposed APIs of the pool rather than being part of the pool implementation itself.

For that to work the pool will need at least one new method that provides access to the currently queued objects without removing them from the pool. For objects not part of the pool a new sync pre_return hook could be added that can be used to filter out objects. This hook could then either spawn a new async task taking ownership of the Object and call Object::take in order to discard it.

bikeshedder avatar Nov 05 '21 16:11 bikeshedder

I would also like this. For example if the max_size has not yet been reached, it would be great to have 1 additional and unused connection ready to handle any incoming requests if other connections in the pool are busy.

JosiahParry avatar Aug 13 '23 13:08 JosiahParry

I would also like this. My shitty SQL database takes over 15 seconds to connect.

bbigras avatar Oct 27 '23 17:10 bbigras

@bbigras thank you for saying it like it is <3 boi do i feel that

JosiahParry avatar Oct 27 '23 18:10 JosiahParry