aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortesseract <tesseract@yandex-team.com>2023-09-26 10:25:00 +0300
committertesseract <tesseract@yandex-team.com>2023-09-26 10:51:35 +0300
commit7f5fa7847bc90dfa488ddfa3e4d9c2aa2b93e77a (patch)
tree781dd2183e80223303cdeacde9b1e27c55cfeb4c
parentd101cf69457801d89fa57434f6257d8c1f1a1c6a (diff)
downloadydb-7f5fa7847bc90dfa488ddfa3e4d9c2aa2b93e77a.tar.gz
Optimize copy big blobs for Kafka write
-rw-r--r--ydb/core/raw_socket/sock_impl.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/ydb/core/raw_socket/sock_impl.h b/ydb/core/raw_socket/sock_impl.h
index 642a59e248..d3e93c9873 100644
--- a/ydb/core/raw_socket/sock_impl.h
+++ b/ydb/core/raw_socket/sock_impl.h
@@ -135,9 +135,19 @@ public:
}
size_t left = length - possible;
if (left >= BufferSize) {
- Buffer.Reserve(left);
- Buffer.Append(src + possible, left);
- flush();
+ if (Chunks.empty()) {
+ // optimization for reduce memory copy
+ ssize_t res = Socket->Send(src + possible, left);
+ if (res > 0) {
+ left -= res;
+ possible += res;
+ }
+ }
+ if (left > 0) {
+ Buffer.Reserve(left);
+ Buffer.Append(src + possible, left);
+ flush();
+ }
} else if (left > 0) {
Buffer.Append(src + possible, left);
}