danielealbano / cachegrand

cachegrand - a modern data ingestion, processing and serving platform built for today's hardware
BSD 3-Clause "New" or "Revised" License
975 stars 34 forks source link

140 Improve pipeline performances buffering the data to be sent via network_send #163

Closed danielealbano closed 2 years ago

danielealbano commented 2 years ago

This PR add support for send buffering to allow pipelining to be efficient, now the network stack will only send data and carry out the fiber switch only if requested or if the buffer is full. To avoid multiple copies a "slices" mechanism has been implemented where the code can request for a slice long up to X and then return it indicating it has used Y, to avoid having to do complex calculations in advance. The network_send has been renamed in network_send_buffered, a network_flush_send_buffer has been introduced to flush the send buffer and a network_send_direct has been introduced to send the data immediately without waiting. When using networksend* functions it's not allowed to have slices opened, this is checked with asserts in debug builds but for performance reasons it's not checked in release builds.

On a side, bugs in the counting of the TLS connections and in the management of maximum amount of allowed connections have been fixed and, in addition, also the internal string comparisons functions have been replaced with the standard ones as the after benchmarking (included in the PR) seems that the last version of Ubuntu is faster than the previous and now the internal ones are a bit slower.

Closes #140

codecov[bot] commented 2 years ago

Codecov Report

Merging #163 (791cf39) into main (879ff64) will decrease coverage by 0.51%. The diff coverage is 69.00%.

@@            Coverage Diff             @@
##             main     #163      +/-   ##
==========================================
- Coverage   77.80%   77.29%   -0.52%     
==========================================
  Files          94       94              
  Lines        6190     6324     +134     
==========================================
+ Hits         4816     4888      +72     
- Misses       1374     1436      +62     
Impacted Files Coverage Δ
src/network/channel/network_channel_tls.c 1.24% <0.00%> (ø)
src/network/network_tls.c 72.22% <0.00%> (ø)
src/slab_allocator.c 97.40% <ø> (ø)
src/utils_string.c 80.00% <ø> (ø)
...dis/command/network_protocol_redis_command_hello.c 61.90% <31.57%> (-4.77%) :arrow_down:
...redis/command/network_protocol_redis_command_get.c 57.80% <38.88%> (-8.23%) :arrow_down:
...rc/network/protocol/redis/network_protocol_redis.c 77.96% <60.27%> (-2.73%) :arrow_down:
.../command/network_protocol_redis_command_shutdown.c 76.19% <63.63%> (-2.76%) :arrow_down:
...edis/command/network_protocol_redis_command_ping.c 76.47% <71.42%> (-1.31%) :arrow_down:
...edis/command/network_protocol_redis_command_quit.c 73.68% <75.00%> (-4.10%) :arrow_down:
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 879ff64...791cf39. Read the comment docs.

lgtm-com[bot] commented 2 years ago

This pull request fixes 1 alert when merging 791cf39258db431c12b6e5244040c36290c68169 into 879ff6444ed116f855f4d0cb58356e3f3e8734d3 - view on LGTM.com

fixed alerts: