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

Method TestSkipCache

be/src/codegen/llvm-codegen-cache-test.cc:434–469  ·  view source on GitHub ↗

Test the case if we have a cache but doesn't contain the function we want, should switch to the cache missing path.

Source from the content-addressed store, hash-verified

432/// Test the case if we have a cache but doesn't contain the function
433/// we want, should switch to the cache missing path.
434void LlvmCodeGenCacheTest::TestSkipCache() {
435 // Initial a LlvmCodeGen object with a normal function.
436 scoped_ptr<LlvmCodeGen> codegen;
437 ASSERT_OK(LlvmCodeGen::CreateImpalaCodegen(fragment_state_, nullptr, "test", &codegen));
438 AddLlvmCodegenEcho(codegen.get());
439 // Create an empty function from other LlvmCodeGen to create the failure later.
440 scoped_ptr<LlvmCodeGen> codegen_empty;
441 ASSERT_OK(LlvmCodeGen::CreateImpalaCodegen(
442 fragment_state_, nullptr, "test_empty", &codegen_empty));
443 llvm::Function* empty_func;
444 GetLlvmEmptyFunction(codegen_empty.get(), &empty_func);
445
446 test_env_->ResetCodegenCache(metrics_.get());
447 EXPECT_OK(test_env_->codegen_cache()->Init(CODEGEN_CACHE_CAPACITY));
448
449 CheckMetrics(test_env_->codegen_cache(), 0 /*hit*/, 0 /*miss*/, 0 /*evict*/);
450 CodeGenCacheKey cache_key;
451 string key = "key";
452 CodeGenCacheKeyConstructor::construct(key, &cache_key);
453 codegen->GenerateFunctionNamesHashCode();
454 // Store and lookup the entry by the key, should be successful.
455 EXPECT_OK(codegen->StoreCache(cache_key));
456 EXPECT_TRUE(codegen->LookupCache(cache_key));
457 CheckMetrics(test_env_->codegen_cache(), 1 /*hit*/, 0 /*miss*/, 0 /*evict*/);
458 CodegenFnPtr<TestEmpty> fn_ptr;
459 // Insert a new function to the codegen, and regenerate the function names hash
460 // code, expect a failure because the hash code inconsistency with the code in
461 // the cache.
462 codegen->AddFunctionToJitInternal(empty_func, &fn_ptr);
463 codegen->GenerateFunctionNamesHashCode();
464 // Expect a look up failure.
465 EXPECT_FALSE(codegen->LookupCache(cache_key));
466 CheckMetrics(test_env_->codegen_cache(), 1 /*hit*/, 1 /*miss*/, 0 /*evict*/);
467 codegen->Close();
468 codegen_empty->Close();
469}
470
471// Test the basic function of using the codegen cache.
472TEST_F(LlvmCodeGenCacheTest, BasicFunction) {

Callers

nothing calls this directly

Calls 9

ResetCodegenCacheMethod · 0.80
StoreCacheMethod · 0.80
LookupCacheMethod · 0.80
getMethod · 0.65
InitMethod · 0.45
codegen_cacheMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected