MCPcopy Create free account
hub / github.com/facebook/CacheLib / runFindOps

Function runFindOps

cachelib/benchmarks/EventTrackerPerf.cpp:53–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51std::unique_ptr<LruAllocator> cache;
52
53void runFindOps(std::shared_ptr<FakeWsaTracker> tracker) {
54 BENCHMARK_SUSPEND {
55 LruAllocator::Config config;
56
57 config.setCacheSize(500ul * 1024ul * 1024ul); // 500 MB
58
59 // 16 million buckets, 1 million locks
60 LruAllocator::AccessConfig accessConfig{24 /* buckets power */,
61 20 /* locks power */};
62 config.setAccessConfig(accessConfig);
63 config.configureChainedItems(accessConfig);
64
65 if (tracker) {
66 config.setEventTracker(std::move(tracker));
67 }
68
69 cache = std::make_unique<LruAllocator>(config);
70 cache->addPool("default", cache->getCacheMemoryStats().ramCacheSize);
71
72 auto hdl = cache->allocate(0, "my key", 100);
73 for (int i = 0; i < 10; i++) {
74 auto c = cache->allocateChainedItem(hdl, 100);
75 cache->addChainedItem(hdl, std::move(c));
76 }
77 cache->insert(hdl);
78 }
79
80 for (int i = 0; i < 1'000'000; i++) {
81 auto hdl = cache->find("my key");

Callers 2

BENCHMARKFunction · 0.85
BENCHMARK_RELATIVEFunction · 0.85

Calls 7

setEventTrackerMethod · 0.45
addPoolMethod · 0.45
getCacheMemoryStatsMethod · 0.45
allocateMethod · 0.45
allocateChainedItemMethod · 0.45
addChainedItemMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected