MCPcopy Create free account
hub / github.com/apache/impala / Lookup

Method Lookup

be/src/codegen/llvm-codegen-cache.cc:110–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110Status CodeGenCache::Lookup(const CodeGenCacheKey& cache_key,
111 const TCodeGenCacheMode::type& mode, CodeGenCacheEntry* entry,
112 shared_ptr<CodeGenObjectCache>* cached_engine) {
113 DCHECK(!is_closed_);
114 DCHECK(cache_ != nullptr);
115 DCHECK(entry != nullptr);
116 DCHECK(cached_engine != nullptr);
117 // Use hash code and the total length as the key for optimal mode, because the whole
118 // key could be very large, using optimal mode could improve the performance and save
119 // memory consumption. However, it could lead to a collision, even though the chance
120 // is very small, in that case, we may switch to normal mode for the query or disable
121 // the codegen cache.
122 Slice key;
123 if (CodeGenCacheModeAnalyzer::is_optimal(mode)) {
124 key = cache_key.optimal_key_slice();
125 } else {
126 key = cache_key.data_slice();
127 }
128 Cache::UniqueHandle handle(cache_->Lookup(key));
129 if (handle.get() != nullptr) {
130 const CodeGenCacheEntry* cached_entry =
131 reinterpret_cast<const CodeGenCacheEntry*>(cache_->Value(handle).data());
132 // Need to find the shared pointer of the engine from the cache before return,
133 // because the shared pointer could be deleted in the eviction process.
134 // If can't find it, treat it as cache missing, because the engine is needed
135 // to look for jitted functions.
136 if (LookupEngine(cached_entry->cached_engine_pointer, cached_engine)) {
137 entry->Reset(cached_entry->cached_engine_pointer, cached_entry->num_functions,
138 cached_entry->num_instructions, cached_entry->num_opt_functions,
139 cached_entry->num_opt_instructions, cached_entry->function_names_hashcode,
140 cached_entry->total_bytes_charge, cached_entry->opt_level);
141 return Status::OK();
142 }
143 }
144 entry->Reset();
145 return Status::OK();
146}
147
148Status CodeGenCache::StoreInternal(const CodeGenCacheKey& cache_key,
149 LlvmCodeGen* codegen, TCodeGenCacheMode::type mode,

Callers 4

TestBasicFunctionMethod · 0.45
CheckKeyExistMethod · 0.45
TestSwitchModeHelperMethod · 0.45
LookupCacheMethod · 0.45

Calls 7

OKFunction · 0.85
optimal_key_sliceMethod · 0.80
data_sliceMethod · 0.80
getMethod · 0.65
dataMethod · 0.45
ValueMethod · 0.45
ResetMethod · 0.45

Tested by 3

TestBasicFunctionMethod · 0.36
CheckKeyExistMethod · 0.36
TestSwitchModeHelperMethod · 0.36