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

Method LookupCache

be/src/codegen/llvm-codegen.cc:1170–1213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1168}
1169
1170bool LlvmCodeGen::LookupCache(CodeGenCacheKey& cache_key) {
1171 DCHECK(!cache_key.empty());
1172 CodeGenCacheEntry entry;
1173 CodeGenCache* cache = ExecEnv::GetInstance()->codegen_cache();
1174 DCHECK(cache != nullptr);
1175 Status lookup_status = cache->Lookup(cache_key,
1176 state_->query_options().codegen_cache_mode, &entry, &engine_cache_cached_);
1177 bool entry_exists = lookup_status.ok() && !entry.Empty();
1178 LOG(INFO) << DebugCacheEntryString(cache_key, true /*is_lookup*/,
1179 CodeGenCacheModeAnalyzer::is_debug(state_->query_options().codegen_cache_mode),
1180 entry_exists);
1181 if (entry_exists) {
1182 // Fallback to normal procedure if function names hashcode is not expected.
1183 // The names hashcode should be the same unless there is a collision on the
1184 // key, we expect this case is very rare.
1185 if (function_names_hashcode_ != entry.function_names_hashcode) {
1186 LOG(WARNING)
1187 << "The codegen cache entry contains a different function names hashcode: "
1188 << " function names hashcode expected: " << function_names_hashcode_
1189 << " actual: " << entry.function_names_hashcode
1190 << " key hash_code=" << cache_key.hash_code();
1191 cache->IncHitOrMissCount(/*hit*/ false);
1192 return false;
1193 }
1194
1195 if (entry.opt_level < state_->query_options().codegen_opt_level) {
1196 // Requested optimization level is higher than cached entry, so treat as a miss.
1197 VLOG(2) << "Overwriting codegen cache entry at " << entry.opt_level
1198 << " with optimization level " << state_->query_options().codegen_opt_level;
1199 cache->IncHitOrMissCount(/*hit*/ false);
1200 return false;
1201 }
1202
1203 // Because we cache all the compiled codegened functions, the cached number of
1204 // functions should be the same as the total optimized function number.
1205 COUNTER_SET(num_cached_functions_, entry.num_opt_functions);
1206 COUNTER_SET(num_functions_, entry.num_functions);
1207 COUNTER_SET(num_instructions_, entry.num_instructions);
1208 COUNTER_SET(num_opt_functions_, entry.num_opt_functions);
1209 COUNTER_SET(num_opt_instructions_, entry.num_opt_instructions);
1210 }
1211 cache->IncHitOrMissCount(/*hit*/ entry_exists);
1212 return entry_exists;
1213}
1214
1215string LlvmCodeGen::GetAllFunctionNames() {
1216 stringstream result;

Callers 2

TestAtCapacityMethod · 0.80
TestSkipCacheMethod · 0.80

Calls 7

hash_codeMethod · 0.80
IncHitOrMissCountMethod · 0.80
emptyMethod · 0.45
codegen_cacheMethod · 0.45
LookupMethod · 0.45
okMethod · 0.45
EmptyMethod · 0.45

Tested by 2

TestAtCapacityMethod · 0.64
TestSkipCacheMethod · 0.64