aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanilalexeev <danilalexeev@yandex-team.com>2023-08-28 20:26:48 +0300
committerdanilalexeev <danilalexeev@yandex-team.com>2023-08-28 21:40:05 +0300
commitb8e0cc38b5bf4b1ddef0a5058693843401fc5778 (patch)
tree1500ec5fdf8bbe30ab0cf6f8eed21790ba7c6d00
parent10b2c18f94e2a2f1634031c144f24f12adf00eac (diff)
downloadydb-b8e0cc38b5bf4b1ddef0a5058693843401fc5778.tar.gz
YT-19714: Parallel load values for few instances of EntityMap (chunks and chunk lists)
-rw-r--r--yt/yt/core/misc/serialize-inl.h6
-rw-r--r--yt/yt/core/misc/serialize.cpp11
-rw-r--r--yt/yt/core/misc/serialize.h6
3 files changed, 23 insertions, 0 deletions
diff --git a/yt/yt/core/misc/serialize-inl.h b/yt/yt/core/misc/serialize-inl.h
index a3c985f4cc..db38f68fbd 100644
--- a/yt/yt/core/misc/serialize-inl.h
+++ b/yt/yt/core/misc/serialize-inl.h
@@ -376,6 +376,7 @@ TEntitySerializationKey TEntityStreamSaveContext::RegisterRefCountedEntity(const
template <class T>
inline TEntitySerializationKey TEntityStreamLoadContext::RegisterRawEntity(T* entity)
{
+ YT_VERIFY(!ParentContext_);
auto key = TEntitySerializationKey(std::ssize(RawPtrs_));
RawPtrs_.push_back(entity);
return key;
@@ -384,6 +385,7 @@ inline TEntitySerializationKey TEntityStreamLoadContext::RegisterRawEntity(T* en
template <class T>
TEntitySerializationKey TEntityStreamLoadContext::RegisterRefCountedEntity(const TIntrusivePtr<T>& entity)
{
+ YT_VERIFY(!ParentContext_);
auto* ptr = entity.Get();
RefCountedPtrs_.push_back(entity);
return RegisterRawEntity(ptr);
@@ -392,6 +394,10 @@ TEntitySerializationKey TEntityStreamLoadContext::RegisterRefCountedEntity(const
template <class T>
T* TEntityStreamLoadContext::GetRawEntity(TEntitySerializationKey key) const
{
+ if (ParentContext_) {
+ return ParentContext_->GetRawEntity<T>(key);
+ }
+
YT_ASSERT(key.Index >= 0);
YT_ASSERT(key.Index < std::ssize(RawPtrs_));
return static_cast<T*>(RawPtrs_[key.Index]);
diff --git a/yt/yt/core/misc/serialize.cpp b/yt/yt/core/misc/serialize.cpp
index 15b975c194..b5d8720a35 100644
--- a/yt/yt/core/misc/serialize.cpp
+++ b/yt/yt/core/misc/serialize.cpp
@@ -177,5 +177,16 @@ TEntityStreamSaveContext::TEntityStreamSaveContext(
////////////////////////////////////////////////////////////////////////////////
+TEntityStreamLoadContext::TEntityStreamLoadContext(
+ IZeroCopyInput* input,
+ const TEntityStreamLoadContext* parentContext)
+ : TStreamLoadContext(input)
+ , ParentContext_(parentContext)
+{
+ SetVersion(ParentContext_->GetVersion());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
} // namespace NYT
diff --git a/yt/yt/core/misc/serialize.h b/yt/yt/core/misc/serialize.h
index 09a9bb6e9a..165a4442d2 100644
--- a/yt/yt/core/misc/serialize.h
+++ b/yt/yt/core/misc/serialize.h
@@ -263,6 +263,10 @@ class TEntityStreamLoadContext
public:
using TStreamLoadContext::TStreamLoadContext;
+ TEntityStreamLoadContext(
+ IZeroCopyInput* input,
+ const TEntityStreamLoadContext* parentContext);
+
template <class T>
TEntitySerializationKey RegisterRawEntity(T* entity);
template <class T>
@@ -274,6 +278,8 @@ public:
TIntrusivePtr<T> GetRefCountedEntity(TEntitySerializationKey key) const;
private:
+ const TEntityStreamLoadContext* const ParentContext_ = nullptr;
+
std::vector<void*> RawPtrs_;
std::vector<TIntrusivePtr<TRefCounted>> RefCountedPtrs_;
};