Skip to content

Commit 78801f7

Browse files
kungablinkov
authored andcommitted
Shared Cache owner is sender (#15891)
1 parent 07e283d commit 78801f7

File tree

6 files changed

+75
-94
lines changed

6 files changed

+75
-94
lines changed

ydb/core/tablet_flat/flat_executor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ void TExecutor::AddCachesOfBundle(const NTable::TPartView &partView)
691691
void TExecutor::AddSingleCache(const TIntrusivePtr<TPrivatePageCache::TInfo> &info)
692692
{
693693
PrivatePageCache->RegisterPageCollection(info);
694-
Send(MakeSharedPageCacheId(), new NSharedCache::TEvAttach(info->PageCollection, SelfId()));
694+
Send(MakeSharedPageCacheId(), new NSharedCache::TEvAttach(info->PageCollection));
695695

696696
StickyPagesMemory += info->GetStickySize();
697697

@@ -1179,8 +1179,7 @@ void TExecutor::RequestFromSharedCache(TAutoPtr<NPageCollection::TFetch> fetch,
11791179

11801180
Send(MakeSharedPageCacheId(), new NSharedCache::TEvRequest(
11811181
priority,
1182-
fetch,
1183-
SelfId()),
1182+
fetch),
11841183
0, (ui64)requestCategory);
11851184
}
11861185

ydb/core/tablet_flat/flat_executor_bootlogic.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ NBoot::TSpawned TExecutorBootLogic::LoadPages(NBoot::IStep *step, TAutoPtr<NPage
184184
NSharedCache::MakeSharedPageCacheId(),
185185
new NSharedCache::TEvRequest(
186186
NBlockIO::EPriority::Fast,
187-
req,
188-
SelfId),
187+
req),
189188
0, (ui64)EPageCollectionRequest::BootLogic);
190189

191190
return NBoot::TSpawned(true);

ydb/core/tablet_flat/flat_scan_actor.h

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ namespace NOps {
8282
enum EEv {
8383
EvLoadBlob = EventSpaceBegin(TKikimrEvents::ES_PRIVATE),
8484
EvBlobLoaded,
85-
EvLoadPages,
8685
EvPartLoaded,
8786
EvPartFailed,
8887
};
@@ -107,14 +106,6 @@ namespace NOps {
107106
{ }
108107
};
109108

110-
struct TEvLoadPages : public TEventLocal<TEvLoadPages, EvLoadPages> {
111-
TAutoPtr<NPageCollection::TFetch> Request;
112-
113-
TEvLoadPages(TAutoPtr<NPageCollection::TFetch> request)
114-
: Request(std::move(request))
115-
{ }
116-
};
117-
118109
struct TEvPartLoaded : public TEventLocal<TEvPartLoaded, EvPartLoaded> {
119110
TPartView Part;
120111

@@ -135,9 +126,10 @@ namespace NOps {
135126
private:
136127
class TColdPartLoader : public ::NActors::TActorBootstrapped<TColdPartLoader> {
137128
public:
138-
TColdPartLoader(TActorId owner, TIntrusiveConstPtr<TColdPartStore> part)
129+
TColdPartLoader(TActorId owner, TIntrusiveConstPtr<TColdPartStore> part, EPriority readPriority)
139130
: Owner(owner)
140131
, Part(std::move(part))
132+
, ReadPriority(readPriority)
141133
{ }
142134

143135
void Bootstrap() {
@@ -195,7 +187,7 @@ namespace NOps {
195187

196188
void RunLoader() {
197189
for (auto req : Loader->Run({.PreloadIndex = false, .PreloadData = false})) {
198-
Send(Owner, new TEvPrivate::TEvLoadPages(std::move(req)));
190+
Send(MakeSharedPageCacheId(), new NSharedCache::TEvRequest(ReadPriority, req));
199191
++ReadsLeft;
200192
}
201193

@@ -209,6 +201,7 @@ namespace NOps {
209201
STRICT_STFUNC(StateLoadPart, {
210202
sFunc(TEvents::TEvPoison, PassAway);
211203
hFunc(NSharedCache::TEvResult, Handle);
204+
hFunc(NBlockIO::TEvStat, Handle);
212205
});
213206

214207
void Handle(NSharedCache::TEvResult::TPtr& ev) {
@@ -229,9 +222,20 @@ namespace NOps {
229222
}
230223
}
231224

225+
void Handle(NBlockIO::TEvStat::TPtr& ev) {
226+
ev->Rewrite(ev->GetTypeRewrite(), Owner);
227+
TActivationContext::Send(ev.Release());
228+
}
229+
230+
void PassAway() override {
231+
Send(MakeSharedPageCacheId(), new NSharedCache::TEvUnregister);
232+
TActorBootstrapped::PassAway();
233+
}
234+
232235
private:
233236
TActorId Owner;
234237
TIntrusiveConstPtr<TColdPartStore> Part;
238+
EPriority ReadPriority;
235239
TVector<TIntrusivePtr<TPrivatePageCache::TInfo>> PageCollections;
236240
TVector<NPageCollection::TLargeGlobIdRestoreState> PageCollectionLoaders;
237241
size_t PageCollectionsLeft = 0;
@@ -306,7 +310,7 @@ namespace NOps {
306310
// Create a loader for this new part
307311
TIntrusiveConstPtr<TColdPartStore> partStore = dynamic_cast<TColdPartStore*>(const_cast<TColdPart*>(part.Get()));
308312
Y_VERIFY_S(partStore, "Cannot load unsupported part " << NFmt::Do(*part));
309-
ColdPartLoaders[label] = RegisterWithSameMailbox(new TColdPartLoader(SelfId(), std::move(partStore)));
313+
ColdPartLoaders[label] = RegisterWithSameMailbox(new TColdPartLoader(SelfId(), std::move(partStore), Args.ReadPrio));
310314
}
311315

312316
// Return empty TPartView to signal loader is still in progress
@@ -359,7 +363,6 @@ namespace NOps {
359363
hFunc(TEvContinue, Handle);
360364
hFunc(TEvPrivate::TEvLoadBlob, Handle);
361365
hFunc(TEvBlobStorage::TEvGetResult, Handle);
362-
hFunc(TEvPrivate::TEvLoadPages, Handle);
363366
hFunc(NBlockIO::TEvStat, Handle);
364367
hFunc(TEvPrivate::TEvPartLoaded, Handle);
365368
hFunc(TEvPrivate::TEvPartFailed, Handle);
@@ -484,7 +487,7 @@ namespace NOps {
484487
if (auto logl = Logger->Log(ELnLev::Debug))
485488
logl << NFmt::Do(*this) << " " << NFmt::Do(*req);
486489

487-
Send(MakeSharedPageCacheId(), new NSharedCache::TEvRequest(Args.ReadPrio, req, SelfId()));
490+
Send(MakeSharedPageCacheId(), new NSharedCache::TEvRequest(Args.ReadPrio, req));
488491
}
489492

490493
if (ready == NTable::EReady::Page)
@@ -560,16 +563,6 @@ namespace NOps {
560563
}
561564
}
562565

563-
void Handle(TEvPrivate::TEvLoadPages::TPtr& ev)
564-
{
565-
auto* msg = ev->Get();
566-
567-
TActorIdentity(ev->Sender).Send(
568-
MakeSharedPageCacheId(),
569-
new NSharedCache::TEvRequest(Args.ReadPrio, std::move(msg->Request), SelfId()),
570-
ev->Flags, ev->Cookie);
571-
}
572-
573566
void Handle(NBlockIO::TEvStat::TPtr& ev)
574567
{
575568
ev->Rewrite(ev->GetTypeRewrite(), Owner);

ydb/core/tablet_flat/shared_cache_events.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,10 @@ namespace NKikimr::NSharedCache {
5555

5656
struct TEvAttach : public TEventLocal<TEvAttach, EvAttach> {
5757
TIntrusiveConstPtr<NPageCollection::IPageCollection> PageCollection;
58-
TActorId Owner;
5958

60-
TEvAttach(TIntrusiveConstPtr<NPageCollection::IPageCollection> pageCollection, TActorId owner)
59+
TEvAttach(TIntrusiveConstPtr<NPageCollection::IPageCollection> pageCollection)
6160
: PageCollection(std::move(pageCollection))
62-
, Owner(owner)
6361
{
64-
Y_ABORT_UNLESS(Owner, "Cannot send request with empty owner");
6562
}
6663
};
6764

@@ -81,14 +78,11 @@ namespace NKikimr::NSharedCache {
8178
struct TEvRequest : public TEventLocal<TEvRequest, EvRequest> {
8279
const EPriority Priority;
8380
TAutoPtr<NPageCollection::TFetch> Fetch;
84-
TActorId Owner;
8581

86-
TEvRequest(EPriority priority, TAutoPtr<NPageCollection::TFetch> fetch, TActorId owner)
82+
TEvRequest(EPriority priority, TAutoPtr<NPageCollection::TFetch> fetch)
8783
: Priority(priority)
8884
, Fetch(fetch)
89-
, Owner(owner)
9085
{
91-
Y_ABORT_UNLESS(Owner, "Cannot sent request with empty owner");
9286
}
9387
};
9488

0 commit comments

Comments
 (0)