cpp-bredis
cpp-bredis copied to clipboard
performance improvements ideas
- Introduce
prepared_command, which already holds serialized form, and yous it as item inConstBufferSequence
in other words, the idea is to avoid output (tx) buffer linearization. Currently this technique is used with rx buffer on (and it used completely on the experimental branch).
Avoiding output linearization will really make bredis zero cost, as the user's payload will not be copied by bredis, and will be passed into OS-kernel directly.
@ovanes Here are preliminary experimental PR:
https://github.com/basiliscos/cpp-bredis/blob/prepared-command/examples/speed_test_async_multi.cpp
it uses writev syscall under the hood and performs zero-copy for input commands.
but the performance for the bulk of small commands actually drops to 80..90 times. So, it does not worth in general case, however it might be worth for case when bredis is data-producer, i.e. generates huge amounts of data and feeds it to redis-server.
It might be useful to have mixed mode, i.e. allow linearization as well as zero-copy, but I'll wait further requests/cases from bredis-users.