Skip to content

Commit

Permalink
Minor best-practice fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chenhao-ye committed Sep 18, 2024
1 parent 7f66dda commit a47a93d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Below is an example of LRU cache usage. It allocates a page cache space (2 pages
char* page_cache = new char[4096 * 2]; // allocate a 2-page cache

using Cache_t = gcache::LRUCache</*Key_t*/ uint32_t, /*Value_t*/ char*,
/*Hash*/ gcache::ghash>;
/*Hash*/ gcache::ghash>;
Cache_t lru_cache;
// init: 1) set cache capacity; 2) put page cache pointers into buffer
lru_cache.init(/*capacity*/ 2,
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/bench_ghost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static OffsetType wl_type = OffsetType::ZIPF;
static uint64_t num_blocks = 1024 * 1024 * 1024 / 4096; // 1 GB
static uint64_t num_files = 32;
static uint64_t num_blocks_per_op = 4; // 16K read per op
static uint64_t num_ops = 1'000'000; // 1M
static uint64_t num_ops = 1'000'000; // 1M
static uint64_t preheat_num_ops = num_ops / 10;
static double zipf_theta = 0.99;
static uint64_t rand_seed = 0x537; // enable different runs
Expand Down Expand Up @@ -153,7 +153,7 @@ int main(int argc, char* argv[]) {

uint64_t offset_checksum1 = 0, offset_checksum2 = 0, offset_checksum3 = 0;

gcache::GhostCache ghost_cache(cache_tick, cache_min, cache_max);
gcache::GhostCache<> ghost_cache(cache_tick, cache_min, cache_max);
gcache::SampledGhostCache<SAMPLE_SHIFT> sampled_ghost_cache(
cache_tick, cache_min, cache_max);

Expand Down
4 changes: 2 additions & 2 deletions include/gcache/ghost_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class GhostCache {
// is ((size_idx + 1) * tick) but not if the cache size is (size_idx * tick).
LRUCache<uint32_t, uint32_t, Hash> cache;

using Handle_t = LRUCache<uint32_t, uint32_t, Hash>::Handle_t;
using Node_t = LRUCache<uint32_t, uint32_t, Hash>::Node_t;
using Handle_t = typename LRUCache<uint32_t, uint32_t, Hash>::Handle_t;
using Node_t = typename LRUCache<uint32_t, uint32_t, Hash>::Node_t;
// these must be placed after num_ticks to ensure a correct ctor order
std::vector<Node_t*> size_boundaries;
std::vector<CacheStat> caches_stat;
Expand Down
13 changes: 6 additions & 7 deletions tests/test_ghost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <stdexcept>

#include "gcache/ghost_cache.h"
#include "gcache/node.h"
Expand All @@ -17,7 +16,7 @@ constexpr const uint32_t large_bench_size = 2 * 1024 * 1024; // 8 GB cache
constexpr const uint32_t sample_shift = 5;

void test1() {
GhostCache ghost_cache(1, 3, 6);
GhostCache<> ghost_cache(1, 3, 6);
std::cout << "=== Test 1 ===\n";

ghost_cache.access(0);
Expand Down Expand Up @@ -61,7 +60,7 @@ void test1() {
}

void test2() {
GhostCache ghost_cache(2, 2, 6);
GhostCache<> ghost_cache(2, 2, 6);
std::cout << "=== Test 2 ===\n";

ghost_cache.access(0);
Expand Down Expand Up @@ -107,7 +106,7 @@ void test2() {
}

void bench1() {
GhostCache ghost_cache(bench_size / 32, bench_size / 32, bench_size);
GhostCache<> ghost_cache(bench_size / 32, bench_size / 32, bench_size);

// filling the cache
auto ts0 = rdtsc();
Expand Down Expand Up @@ -170,7 +169,7 @@ void bench2() {
}

void bench3() {
GhostCache ghost_cache(bench_size / 32, bench_size / 32, bench_size);
GhostCache<> ghost_cache(bench_size / 32, bench_size / 32, bench_size);
SampledGhostCache<sample_shift> sampled_ghost_cache(
bench_size / 32, bench_size / 32, bench_size);

Expand Down Expand Up @@ -225,7 +224,7 @@ void bench3() {
}

void bench4() {
GhostCache ghost_cache(large_bench_size / 32, large_bench_size / 32,
GhostCache<> ghost_cache(large_bench_size / 32, large_bench_size / 32,
large_bench_size);
SampledGhostCache<sample_shift> sampled_ghost_cache(
large_bench_size / 32, large_bench_size / 32, large_bench_size);
Expand Down Expand Up @@ -281,7 +280,7 @@ void bench4() {
}

void bench5() {
GhostCache ghost_cache(large_bench_size / 32, large_bench_size / 32,
GhostCache<> ghost_cache(large_bench_size / 32, large_bench_size / 32,
large_bench_size);
SampledGhostCache<sample_shift> sampled_ghost_cache(
large_bench_size / 32, large_bench_size / 32, large_bench_size);
Expand Down

0 comments on commit a47a93d

Please sign in to comment.