mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-24 16:40:38 +00:00
wip: avoid memory allocation during WAL ingestion
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import os
|
||||
import statistics
|
||||
from typing import List
|
||||
|
||||
import time
|
||||
import pytest
|
||||
from fixtures.compare_fixtures import PgCompare
|
||||
from fixtures.benchmark_fixture import MetricReport
|
||||
from fixtures.compare_fixtures import NeonCompare, PgCompare
|
||||
from fixtures.pg_stats import PgStatTable
|
||||
|
||||
from performance.test_perf_pgbench import get_durations_matrix, get_scales_matrix
|
||||
@@ -27,8 +30,14 @@ def test_compare_pg_stats_rw_with_pgbench_default(neon_with_baseline: PgCompare,
|
||||
env.flush()
|
||||
|
||||
with env.record_pg_stats(pg_stats_rw):
|
||||
env.pg_bin.run_capture(
|
||||
['pgbench', f'-T{duration}', f'--random-seed={seed}', '-Mprepared', env.pg.connstr()])
|
||||
env.pg_bin.run_capture([
|
||||
'pgbench',
|
||||
f'-T{duration}',
|
||||
f'--random-seed={seed}',
|
||||
'-Mprepared',
|
||||
'-r',
|
||||
env.pg.connstr()
|
||||
])
|
||||
env.flush()
|
||||
|
||||
|
||||
@@ -51,6 +60,7 @@ def test_compare_pg_stats_wo_with_pgbench_simple_update(neon_with_baseline: PgCo
|
||||
'-N',
|
||||
f'-T{duration}',
|
||||
f'--random-seed={seed}',
|
||||
'-r',
|
||||
'-Mprepared',
|
||||
env.pg.connstr()
|
||||
])
|
||||
@@ -60,12 +70,12 @@ def test_compare_pg_stats_wo_with_pgbench_simple_update(neon_with_baseline: PgCo
|
||||
@pytest.mark.parametrize("seed", get_seeds_matrix())
|
||||
@pytest.mark.parametrize("scale", get_scales_matrix())
|
||||
@pytest.mark.parametrize("duration", get_durations_matrix(5))
|
||||
def test_compare_pg_stats_ro_with_pgbench_select_only(neon_with_baseline: PgCompare,
|
||||
def test_compare_pg_stats_ro_with_pgbench_select_only(neon_compare: NeonCompare,
|
||||
seed: int,
|
||||
scale: int,
|
||||
duration: int,
|
||||
pg_stats_ro: List[PgStatTable]):
|
||||
env = neon_with_baseline
|
||||
env = neon_compare
|
||||
# initialize pgbench
|
||||
env.pg_bin.run_capture(['pgbench', f'-s{scale}', '-i', env.pg.connstr()])
|
||||
env.flush()
|
||||
@@ -77,6 +87,7 @@ def test_compare_pg_stats_ro_with_pgbench_select_only(neon_with_baseline: PgComp
|
||||
f'-T{duration}',
|
||||
f'--random-seed={seed}',
|
||||
'-Mprepared',
|
||||
'-r',
|
||||
env.pg.connstr()
|
||||
])
|
||||
env.flush()
|
||||
@@ -99,3 +110,54 @@ def test_compare_pg_stats_wal_with_pgbench_default(neon_with_baseline: PgCompare
|
||||
env.pg_bin.run_capture(
|
||||
['pgbench', f'-T{duration}', f'--random-seed={seed}', '-Mprepared', env.pg.connstr()])
|
||||
env.flush()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("duration", get_durations_matrix(5))
|
||||
def test_compare_pg_stats_ro_with_simple_read(neon_with_baseline: PgCompare,
|
||||
duration: int,
|
||||
pg_stats_ro: List[PgStatTable]):
|
||||
env = neon_with_baseline
|
||||
|
||||
# initialize test table
|
||||
with env.pg.connect().cursor() as cur:
|
||||
cur.execute("CREATE TABLE foo as select generate_series(1,100000)")
|
||||
|
||||
start = time.time()
|
||||
|
||||
read_latencies = []
|
||||
with env.record_pg_stats(pg_stats_ro):
|
||||
with env.pg.connect().cursor() as cur:
|
||||
while time.time() - start < duration:
|
||||
t = time.time()
|
||||
cur.execute("SELECT * from foo")
|
||||
read_latencies.append(time.time() - t)
|
||||
|
||||
env.zenbenchmark.record("read_latency_max",
|
||||
max(read_latencies),
|
||||
's',
|
||||
MetricReport.LOWER_IS_BETTER)
|
||||
env.zenbenchmark.record("read_latency_avg",
|
||||
statistics.mean(read_latencies),
|
||||
's',
|
||||
MetricReport.LOWER_IS_BETTER)
|
||||
env.zenbenchmark.record("read_latency_stdev",
|
||||
statistics.stdev(read_latencies),
|
||||
's',
|
||||
MetricReport.LOWER_IS_BETTER)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("duration", get_durations_matrix(10))
|
||||
def test_compare_pg_stats_wo_with_simple_write(neon_compare: NeonCompare,
|
||||
duration: int,
|
||||
pg_stats_wo: List[PgStatTable]):
|
||||
env = neon_compare
|
||||
with env.pg.connect().cursor() as cur:
|
||||
cur.execute(
|
||||
"CREATE TABLE foo(key serial primary key, t text default 'foooooooooooooooooooooooooooooooooooooooooooooooooooo')"
|
||||
)
|
||||
|
||||
start = time.time()
|
||||
with env.record_pg_stats(pg_stats_wo):
|
||||
with env.pg.connect().cursor() as cur:
|
||||
while time.time() - start < duration:
|
||||
cur.execute("INSERT INTO foo SELECT FROM generate_series(1,100000)")
|
||||
|
||||
Reference in New Issue
Block a user