mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-06 13:02:55 +00:00
Reformat all python files by black & isort
This commit is contained in:
committed by
Alexander Bayandin
parent
6b2e1d9065
commit
4c2bb43775
@@ -1,28 +1,26 @@
|
||||
import random
|
||||
import time
|
||||
import statistics
|
||||
import threading
|
||||
import time
|
||||
import timeit
|
||||
import pytest
|
||||
from typing import List
|
||||
|
||||
import pytest
|
||||
from fixtures.benchmark_fixture import MetricReport
|
||||
from fixtures.compare_fixtures import NeonCompare
|
||||
from fixtures.log_helper import log
|
||||
|
||||
|
||||
def _record_branch_creation_durations(neon_compare: NeonCompare, durs: List[float]):
|
||||
neon_compare.zenbenchmark.record("branch_creation_duration_max",
|
||||
max(durs),
|
||||
's',
|
||||
MetricReport.LOWER_IS_BETTER)
|
||||
neon_compare.zenbenchmark.record("branch_creation_duration_avg",
|
||||
statistics.mean(durs),
|
||||
's',
|
||||
MetricReport.LOWER_IS_BETTER)
|
||||
neon_compare.zenbenchmark.record("branch_creation_duration_stdev",
|
||||
statistics.stdev(durs),
|
||||
's',
|
||||
MetricReport.LOWER_IS_BETTER)
|
||||
neon_compare.zenbenchmark.record(
|
||||
"branch_creation_duration_max", max(durs), "s", MetricReport.LOWER_IS_BETTER
|
||||
)
|
||||
neon_compare.zenbenchmark.record(
|
||||
"branch_creation_duration_avg", statistics.mean(durs), "s", MetricReport.LOWER_IS_BETTER
|
||||
)
|
||||
neon_compare.zenbenchmark.record(
|
||||
"branch_creation_duration_stdev", statistics.stdev(durs), "s", MetricReport.LOWER_IS_BETTER
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("n_branches", [20])
|
||||
@@ -37,15 +35,16 @@ def test_branch_creation_heavy_write(neon_compare: NeonCompare, n_branches: int)
|
||||
|
||||
# Use aggressive GC and checkpoint settings, so GC and compaction happen more often during the test
|
||||
tenant, _ = env.neon_cli.create_tenant(
|
||||
conf={
|
||||
'gc_period': '5 s',
|
||||
'gc_horizon': f'{4 * 1024 ** 2}',
|
||||
'checkpoint_distance': f'{2 * 1024 ** 2}',
|
||||
'compaction_target_size': f'{1024 ** 2}',
|
||||
'compaction_threshold': '2',
|
||||
# set PITR interval to be small, so we can do GC
|
||||
'pitr_interval': '5 s'
|
||||
})
|
||||
conf={
|
||||
"gc_period": "5 s",
|
||||
"gc_horizon": f"{4 * 1024 ** 2}",
|
||||
"checkpoint_distance": f"{2 * 1024 ** 2}",
|
||||
"compaction_target_size": f"{1024 ** 2}",
|
||||
"compaction_threshold": "2",
|
||||
# set PITR interval to be small, so we can do GC
|
||||
"pitr_interval": "5 s",
|
||||
}
|
||||
)
|
||||
|
||||
def run_pgbench(branch: str):
|
||||
log.info(f"Start a pgbench workload on branch {branch}")
|
||||
@@ -53,15 +52,15 @@ def test_branch_creation_heavy_write(neon_compare: NeonCompare, n_branches: int)
|
||||
pg = env.postgres.create_start(branch, tenant_id=tenant)
|
||||
connstr = pg.connstr()
|
||||
|
||||
pg_bin.run_capture(['pgbench', '-i', connstr])
|
||||
pg_bin.run_capture(['pgbench', '-c10', '-T10', connstr])
|
||||
pg_bin.run_capture(["pgbench", "-i", connstr])
|
||||
pg_bin.run_capture(["pgbench", "-c10", "-T10", connstr])
|
||||
|
||||
pg.stop()
|
||||
|
||||
env.neon_cli.create_branch('b0', tenant_id=tenant)
|
||||
env.neon_cli.create_branch("b0", tenant_id=tenant)
|
||||
|
||||
threads: List[threading.Thread] = []
|
||||
threads.append(threading.Thread(target=run_pgbench, args=('b0', ), daemon=True))
|
||||
threads.append(threading.Thread(target=run_pgbench, args=("b0",), daemon=True))
|
||||
threads[-1].start()
|
||||
|
||||
branch_creation_durations = []
|
||||
@@ -72,13 +71,13 @@ def test_branch_creation_heavy_write(neon_compare: NeonCompare, n_branches: int)
|
||||
p = random.randint(0, i)
|
||||
|
||||
timer = timeit.default_timer()
|
||||
env.neon_cli.create_branch('b{}'.format(i + 1), 'b{}'.format(p), tenant_id=tenant)
|
||||
env.neon_cli.create_branch("b{}".format(i + 1), "b{}".format(p), tenant_id=tenant)
|
||||
dur = timeit.default_timer() - timer
|
||||
|
||||
log.info(f"Creating branch b{i+1} took {dur}s")
|
||||
branch_creation_durations.append(dur)
|
||||
|
||||
threads.append(threading.Thread(target=run_pgbench, args=(f'b{i+1}', ), daemon=True))
|
||||
threads.append(threading.Thread(target=run_pgbench, args=(f"b{i+1}",), daemon=True))
|
||||
threads[-1].start()
|
||||
|
||||
for thread in threads:
|
||||
@@ -92,10 +91,10 @@ def test_branch_creation_heavy_write(neon_compare: NeonCompare, n_branches: int)
|
||||
def test_branch_creation_many(neon_compare: NeonCompare, n_branches: int):
|
||||
env = neon_compare.env
|
||||
|
||||
env.neon_cli.create_branch('b0')
|
||||
env.neon_cli.create_branch("b0")
|
||||
|
||||
pg = env.postgres.create_start('b0')
|
||||
neon_compare.pg_bin.run_capture(['pgbench', '-i', '-s10', pg.connstr()])
|
||||
pg = env.postgres.create_start("b0")
|
||||
neon_compare.pg_bin.run_capture(["pgbench", "-i", "-s10", pg.connstr()])
|
||||
|
||||
branch_creation_durations = []
|
||||
|
||||
@@ -103,7 +102,7 @@ def test_branch_creation_many(neon_compare: NeonCompare, n_branches: int):
|
||||
# random a source branch
|
||||
p = random.randint(0, i)
|
||||
timer = timeit.default_timer()
|
||||
env.neon_cli.create_branch('b{}'.format(i + 1), 'b{}'.format(p))
|
||||
env.neon_cli.create_branch("b{}".format(i + 1), "b{}".format(p))
|
||||
dur = timeit.default_timer() - timer
|
||||
branch_creation_durations.append(dur)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user