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

Method StoreInternal

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

Source from the content-addressed store, hash-verified

146}
147
148Status CodeGenCache::StoreInternal(const CodeGenCacheKey& cache_key,
149 LlvmCodeGen* codegen, TCodeGenCacheMode::type mode,
150 TCodeGenOptLevel::type opt_level) {
151 // In normal mode, we will store the whole key content to the cache.
152 // Otherwise, in optimal mode, we will only store the hash code and length of the key.
153 Slice key;
154 if (CodeGenCacheModeAnalyzer::is_optimal(mode)) {
155 key = cache_key.optimal_key_slice();
156 } else {
157 key = cache_key.data_slice();
158 }
159 // Memory charge includes both key and entry size.
160 int64_t mem_charge = codegen->engine_cache()->objSize() + key.size()
161 + sizeof(CodeGenCacheEntry) + FLAGS_codegen_cache_entry_bytes_charge_overhead;
162 Cache::UniquePendingHandle pending_handle(
163 cache_->Allocate(key, sizeof(CodeGenCacheEntry), mem_charge));
164 if (pending_handle == nullptr) {
165 return Status(Substitute("Couldn't allocate handle for codegen cache entry,"
166 " size: '$0'",
167 mem_charge));
168 }
169 CodeGenCacheEntry* cache_entry =
170 reinterpret_cast<CodeGenCacheEntry*>(cache_->MutableValue(&pending_handle));
171 cache_entry->Reset(codegen->engine_cache(), codegen->num_functions_->value(),
172 codegen->num_instructions_->value(), codegen->num_opt_functions_->value(),
173 codegen->num_opt_instructions_->value(), codegen->function_names_hashcode_,
174 mem_charge, opt_level);
175 StoreEngine(codegen);
176 /// It is thread-safe, but could override the existing entry with the same key.
177 Cache::UniqueHandle cache_handle =
178 cache_->Insert(move(pending_handle), evict_callback_.get());
179 if (cache_handle == nullptr) {
180 RemoveEngine(codegen->engine_cache());
181 return Status(Substitute("Couldn't insert codegen cache entry,"
182 " hash code:'$0', size: '$1'",
183 cache_key.hash_code().str(), mem_charge));
184 }
185 codegen_cache_entries_in_use_->Increment(1);
186 codegen_cache_entries_in_use_bytes_->Increment(mem_charge);
187 codegen_cache_entry_size_stats_->Update(mem_charge);
188 return Status::OK();
189}
190
191Status CodeGenCache::Store(const CodeGenCacheKey& cache_key, LlvmCodeGen* codegen,
192 TCodeGenCacheMode::type mode, TCodeGenOptLevel::type opt_level) {

Callers

nothing calls this directly

Calls 15

SubstituteFunction · 0.85
moveFunction · 0.85
OKFunction · 0.85
optimal_key_sliceMethod · 0.80
data_sliceMethod · 0.80
objSizeMethod · 0.80
engine_cacheMethod · 0.80
hash_codeMethod · 0.80
getMethod · 0.65
StatusClass · 0.50
sizeMethod · 0.45
AllocateMethod · 0.45

Tested by

no test coverage detected