diff options
author | Maksim Kita <kitaetoya@gmail.com> | 2023-07-06 15:09:44 +0000 |
---|---|---|
committer | maksim-kita <maksim-kita@yandex-team.com> | 2023-07-06 18:09:44 +0300 |
commit | cf8a1a8ee31a48cbb8fff6c147c31998ea7bbbab (patch) | |
tree | 03c8998d99068fb5e1f494d097abe47dbc802898 | |
parent | 30e3ddd414f5154499fb48463d9ea3a7ea8d0475 (diff) | |
download | ydb-cf8a1a8ee31a48cbb8fff6c147c31998ea7bbbab.tar.gz |
Cell improve constructor performance
Cell improve constructor performance
Pull Request resolved: #291
-rw-r--r-- | ydb/core/scheme/scheme_tablecell.h | 22 | ||||
-rw-r--r-- | ydb/core/scheme/scheme_tablecell_ut.cpp | 3 |
2 files changed, 18 insertions, 7 deletions
diff --git a/ydb/core/scheme/scheme_tablecell.h b/ydb/core/scheme/scheme_tablecell.h index ff19e1da55..e6d1a62479 100644 --- a/ydb/core/scheme/scheme_tablecell.h +++ b/ydb/core/scheme/scheme_tablecell.h @@ -44,18 +44,28 @@ public: Y_VERIFY(ref.size() < Max<ui32>(), " Too large blob size for TCell"); } - TCell(const char* ptr, ui32 sz) - : DataSize_(sz) + TCell(const char* ptr, ui32 size) + : DataSize_(size) , IsInline_(0) , IsNull_(ptr == nullptr) , Ptr(ptr) { - Y_VERIFY_DEBUG(ptr || sz == 0); - if (CanInline(sz)) { + Y_VERIFY_DEBUG(ptr || size == 0); + + if (CanInline(size)) { IsInline_ = 1; IntVal = 0; - if (ptr) - memcpy(&IntVal, ptr, sz); + + switch (size) { + case 8: memcpy(&IntVal, ptr, 8); break; + case 7: memcpy(&IntVal, ptr, 7); break; + case 6: memcpy(&IntVal, ptr, 6); break; + case 5: memcpy(&IntVal, ptr, 5); break; + case 4: memcpy(&IntVal, ptr, 4); break; + case 3: memcpy(&IntVal, ptr, 3); break; + case 2: memcpy(&IntVal, ptr, 2); break; + case 1: memcpy(&IntVal, ptr, 1); break; + } } } diff --git a/ydb/core/scheme/scheme_tablecell_ut.cpp b/ydb/core/scheme/scheme_tablecell_ut.cpp index 60c7c7d963..49f0391948 100644 --- a/ydb/core/scheme/scheme_tablecell_ut.cpp +++ b/ydb/core/scheme/scheme_tablecell_ut.cpp @@ -148,9 +148,10 @@ Y_UNIT_TEST_SUITE(Scheme) { const int ITERATIONS = 1000;//10000000; { + TString res; TInstant start = TInstant::Now(); for (int i = 0; i < ITERATIONS; ++i) { - TSerializedCellVec::Serialize(cells); + TSerializedCellVec::Serialize(res, cells); } TInstant finish = TInstant::Now(); Cerr << "Serialize: " << finish - start << Endl; |