aerospike / aerospike-client-rust

Rust client for the Aerospike database
https://www.aerospike.com/
Other
82 stars 26 forks source link

Shrink connection buffers to avoid unbounded memory allocation #83

Closed soro closed 4 years ago

soro commented 4 years ago

Make sure to shrink the allocation of the buffers once they have grown past a certain size and we are trying to truncate them. The value is probably something one might want to tune.

soro commented 4 years ago

Pushed the change. I am not convinced it is worth tuning the default parameter too much or spending too much effort on coming up with a smart way of picking that value based on statistics when really that should be something set by the user of the library according to their needs. Any automatic mechanism is also more prone to error in extreme scenarios. A sufficiently high default should be good enough in my opinion. Realistically we could probably make that buffer a max of say 100k, since that is unlikely to every lead to problems with reasonable connection pool sizes.

jhecking commented 4 years ago

I think Khosrow just meant setting a sensible default value and not trying to do anything more complicated like trying dynamically adjust the value based on statistics. These changes now look good and ready to merge to me.

jhecking commented 4 years ago

Thanks again, @soro!

The Travis CI tests with Rust 1.38 are failing, but that's due to an updated subtle dependency, which requires Rust 1.41 in the latest version.