@@ -33,7 +33,7 @@ class TComputationPatternLRUCache::TLRUPatternCacheImpl
33
33
return CurrentPatternsCompiledCodeSizeInBytes;
34
34
}
35
35
36
- std::shared_ptr<TPatternCacheEntry>* Find (const TString & serializedProgram) {
36
+ std::shared_ptr<TPatternCacheEntry>* Find (const TSerializedProgram & serializedProgram) {
37
37
auto it = SerializedProgramToPatternCacheHolder.find (serializedProgram);
38
38
if (it == SerializedProgramToPatternCacheHolder.end ()) {
39
39
return nullptr ;
@@ -44,7 +44,7 @@ class TComputationPatternLRUCache::TLRUPatternCacheImpl
44
44
return &it->second .Entry ;
45
45
}
46
46
47
- void Insert (const TString & serializedProgram, std::shared_ptr<TPatternCacheEntry>& entry) {
47
+ void Insert (const TSerializedProgram & serializedProgram, std::shared_ptr<TPatternCacheEntry>& entry) {
48
48
auto [it, inserted] = SerializedProgramToPatternCacheHolder.emplace (std::piecewise_construct,
49
49
std::forward_as_tuple (serializedProgram),
50
50
std::forward_as_tuple (serializedProgram, entry));
@@ -69,7 +69,7 @@ class TComputationPatternLRUCache::TLRUPatternCacheImpl
69
69
ClearIfNeeded ();
70
70
}
71
71
72
- void NotifyPatternCompiled (const TString & serializedProgram, std::shared_ptr<TPatternCacheEntry>& entry) {
72
+ void NotifyPatternCompiled (const TSerializedProgram & serializedProgram, std::shared_ptr<TPatternCacheEntry>& entry) {
73
73
auto it = SerializedProgramToPatternCacheHolder.find (serializedProgram);
74
74
if (it == SerializedProgramToPatternCacheHolder.end ()) {
75
75
return ;
@@ -108,7 +108,7 @@ class TComputationPatternLRUCache::TLRUPatternCacheImpl
108
108
* Most recently accessed items are in back of the lists, least recently accessed items are in front of the lists.
109
109
*/
110
110
struct TPatternCacheHolder : public TIntrusiveListItem <TPatternCacheHolder, TPatternLRUListTag>, TIntrusiveListItem<TPatternCacheHolder, TCompiledPatternLRUListTag> {
111
- TPatternCacheHolder (TString serializedProgram, std::shared_ptr<TPatternCacheEntry> entry)
111
+ TPatternCacheHolder (TSerializedProgram serializedProgram, std::shared_ptr<TPatternCacheEntry> entry)
112
112
: SerializedProgram(std::move(serializedProgram))
113
113
, Entry(std::move(entry))
114
114
{}
@@ -121,7 +121,7 @@ class TComputationPatternLRUCache::TLRUPatternCacheImpl
121
121
return !TIntrusiveListItem<TPatternCacheHolder, TCompiledPatternLRUListTag>::Empty ();
122
122
}
123
123
124
- TString SerializedProgram;
124
+ TSerializedProgram SerializedProgram;
125
125
std::shared_ptr<TPatternCacheEntry> Entry;
126
126
};
127
127
@@ -195,7 +195,7 @@ class TComputationPatternLRUCache::TLRUPatternCacheImpl
195
195
size_t CurrentCompiledPatternsSize = 0 ;
196
196
size_t CurrentPatternsCompiledCodeSizeInBytes = 0 ;
197
197
198
- THashMap<TString , TPatternCacheHolder> SerializedProgramToPatternCacheHolder;
198
+ THashMap<TSerializedProgram , TPatternCacheHolder> SerializedProgramToPatternCacheHolder;
199
199
TIntrusiveList<TPatternCacheHolder, TPatternLRUListTag> LRUPatternList;
200
200
TIntrusiveList<TPatternCacheHolder, TCompiledPatternLRUListTag> LRUCompiledPatternList;
201
201
};
@@ -223,7 +223,7 @@ TComputationPatternLRUCache::~TComputationPatternLRUCache() {
223
223
CleanCache ();
224
224
}
225
225
226
- std::shared_ptr<TPatternCacheEntry> TComputationPatternLRUCache::Find (const TString & serializedProgram) {
226
+ std::shared_ptr<TPatternCacheEntry> TComputationPatternLRUCache::Find (const TSerializedProgram & serializedProgram) {
227
227
std::lock_guard<std::mutex> lock (Mutex);
228
228
if (auto it = Cache->Find (serializedProgram)) {
229
229
++*Hits;
@@ -238,7 +238,7 @@ std::shared_ptr<TPatternCacheEntry> TComputationPatternLRUCache::Find(const TStr
238
238
return {};
239
239
}
240
240
241
- TComputationPatternLRUCache::TTicket TComputationPatternLRUCache::FindOrSubscribe (const TString & serializedProgram) {
241
+ TComputationPatternLRUCache::TTicket TComputationPatternLRUCache::FindOrSubscribe (const TSerializedProgram & serializedProgram) {
242
242
std::lock_guard lock (Mutex);
243
243
if (auto it = Cache->Find (serializedProgram)) {
244
244
++*Hits;
@@ -263,7 +263,7 @@ TComputationPatternLRUCache::TTicket TComputationPatternLRUCache::FindOrSubscrib
263
263
return TTicket (serializedProgram, false , promise, nullptr );
264
264
}
265
265
266
- void TComputationPatternLRUCache::EmplacePattern (const TString & serializedProgram, std::shared_ptr<TPatternCacheEntry> patternWithEnv) {
266
+ void TComputationPatternLRUCache::EmplacePattern (const TSerializedProgram & serializedProgram, std::shared_ptr<TPatternCacheEntry> patternWithEnv) {
267
267
Y_DEBUG_ABORT_UNLESS (patternWithEnv && patternWithEnv->Pattern );
268
268
TMaybe<TVector<NThreading::TPromise<std::shared_ptr<TPatternCacheEntry>>>> subscribers;
269
269
@@ -290,7 +290,7 @@ void TComputationPatternLRUCache::EmplacePattern(const TString& serializedProgra
290
290
}
291
291
}
292
292
293
- void TComputationPatternLRUCache::NotifyPatternCompiled (const TString & serializedProgram, std::shared_ptr<TPatternCacheEntry> patternWithEnv) {
293
+ void TComputationPatternLRUCache::NotifyPatternCompiled (const TSerializedProgram & serializedProgram, std::shared_ptr<TPatternCacheEntry> patternWithEnv) {
294
294
std::lock_guard lock (Mutex);
295
295
Cache->NotifyPatternCompiled (serializedProgram, patternWithEnv);
296
296
}
@@ -309,7 +309,7 @@ void TComputationPatternLRUCache::CleanCache() {
309
309
Cache->Clear ();
310
310
}
311
311
312
- void TComputationPatternLRUCache::AccessPattern (const TString & serializedProgram, std::shared_ptr<TPatternCacheEntry> & entry) {
312
+ void TComputationPatternLRUCache::AccessPattern (const TSerializedProgram & serializedProgram, std::shared_ptr<TPatternCacheEntry> & entry) {
313
313
if (!Configuration.PatternAccessTimesBeforeTryToCompile || entry->Pattern ->IsCompiled ()) {
314
314
return ;
315
315
}
@@ -321,11 +321,11 @@ void TComputationPatternLRUCache::AccessPattern(const TString & serializedProgra
321
321
}
322
322
}
323
323
324
- void TComputationPatternLRUCache::NotifyMissing (const TString& serialized ) {
324
+ void TComputationPatternLRUCache::NotifyMissing (const TSerializedProgram& serializedProgram ) {
325
325
TMaybe<TVector<NThreading::TPromise<std::shared_ptr<TPatternCacheEntry>>>> subscribers;
326
326
{
327
327
std::lock_guard<std::mutex> lock (Mutex);
328
- auto notifyIt = Notify.find (serialized );
328
+ auto notifyIt = Notify.find (serializedProgram );
329
329
if (notifyIt != Notify.end ()) {
330
330
subscribers.swap (notifyIt->second );
331
331
Notify.erase (notifyIt);
0 commit comments