mirror of
https://github.com/neondatabase/neon.git
synced 2026-06-02 04:50:38 +00:00
Fix test
This commit is contained in:
@@ -137,7 +137,7 @@ addSHLL(HyperLogLogState *cState, uint32 hash)
|
||||
uint32 cell = Min(interval_log2, HIST_SIZE-1);
|
||||
new_histogram[cell] += cState->regs[index][count].histogram[i];
|
||||
}
|
||||
memcpy(cState->regs[index][count].histogram, new_histogram, sizeof new_hostogram);
|
||||
memcpy(cState->regs[index][count].histogram, new_histogram, sizeof new_histogram);
|
||||
}
|
||||
cState->regs[index][count].ts = now;
|
||||
cState->regs[index][count].histogram[0] += 1;
|
||||
@@ -166,7 +166,7 @@ getMaximum(const HyperLogLogRegister* reg, TimestampTz since, time_t duration, d
|
||||
{
|
||||
for (i = 0; i < HLL_C_BITS + 1; i++)
|
||||
{
|
||||
if (reg[i].ts >= since && 1.0 - getAccessCount(reg, duration) / total_count >= min_hit_ration)
|
||||
if (reg[i].ts >= since && 1.0 - getAccessCount(reg, duration) / total_count >= min_hit_ratio)
|
||||
{
|
||||
max = i;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ def test_optimal_cache_size_approximation(neon_simple_env: NeonEnv):
|
||||
)
|
||||
conn = endpoint.connect()
|
||||
cur = conn.cursor()
|
||||
cur.execute("create extension neon")
|
||||
cur.execute("create extension neon version '1.5'")
|
||||
cur.execute(
|
||||
"create table t_huge(pk integer primary key, count integer default 0, payload text default repeat('?', 128))"
|
||||
)
|
||||
@@ -138,14 +138,18 @@ def test_optimal_cache_size_approximation(neon_simple_env: NeonEnv):
|
||||
"create table t_small(pk integer primary key, count integer default 0, payload text default repeat('?', 128))"
|
||||
)
|
||||
cur.execute("insert into t_huge(pk) values (generate_series(1,1000000))")
|
||||
cur.execute("insert into t_small (pk) values (generate_series(1,100000))")
|
||||
cur.execute("insert into t_small(pk) values (generate_series(1,100000))")
|
||||
time.sleep(2)
|
||||
before = time.monotonic()
|
||||
for _ in 1..100:
|
||||
for _ in range(100):
|
||||
cur.execute("select sum(count) from t_small")
|
||||
cur.execute("select sum(count) from t_huge")
|
||||
after = time.monotonic()
|
||||
cur.execute(f"select approximate_optimal_cache_size({int(after - before + 1, 0.99)})")
|
||||
estimation = cur.fetchall()[0][0]
|
||||
log.info(f"Working set size for selecting 1k records {estimation}")
|
||||
assert estimation_1k >= 20 and estimation_1k <= 40
|
||||
cur.execute(f"select approximate_working_set_size_seconds({int(after - before + 1)})")
|
||||
ws_estimation = cur.fetchall()[0][0]
|
||||
log.info(f"Working set size estimaton {ws_estimation}")
|
||||
cur.execute(f"select approximate_optimal_cache_size({int(after - before + 1)}, 0.99)")
|
||||
optimal_cache_size = cur.fetchall()[0][0]
|
||||
log.info(f"Optimal cache size for 99% hit rate {optimal_cache_size}")
|
||||
assert ws_estimation >= 1000 and ws_estimation <= 2000
|
||||
assert optimal_cache_size >= 100 and optimal_cache_size <= 200
|
||||
|
||||
Reference in New Issue
Block a user