Skip to content

Commit

Permalink
Resolved comments:
Browse files Browse the repository at this point in the history
- Added postgres version query in queries.json
- Added pg_prewarm and get_stats functions in run-dann and run-hnsw.
- Deleted custom-dataset run and config script.
- Fixed key issues in hnsw and pvs-sbq run scripts
  • Loading branch information
Sheharyar570 committed Dec 13, 2024
1 parent b36a3af commit b0d2736
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 404 deletions.
4 changes: 4 additions & 0 deletions run-scripts/queries.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[
{
"description": "Postgresql Version",
"query": "SELECT version();"
},
{
"description": "List of extensions installed on postgersql server",
"query": "SELECT extname AS name, extversion AS version FROM pg_extension ORDER BY extname;"
Expand Down
263 changes: 0 additions & 263 deletions run-scripts/run-custom-dataset.py

This file was deleted.

57 changes: 57 additions & 0 deletions run-scripts/run-dann.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,62 @@ def setup_database(config):
cursor = conn.cursor()
cursor.execute("CREATE EXTENSION IF NOT EXISTS vector;")
cursor.execute("CREATE EXTENSION IF NOT EXISTS pg_diskann;")
cursor.execute("CREATE EXTENSION IF NOT EXISTS pg_buffercache;")
cursor.execute("CREATE EXTENSION IF NOT EXISTS pg_prewarm;")
conn.commit()
conn.close()
except Exception as e:
print(f"Setup failed: {e}")

def get_stats(config):
with open('queries.json', 'r') as file:
queries = json.load(file)
try:
conn = psycopg2.connect(
dbname=config['db-name'],
user=config['username'],
password=config['password'],
host=config['host']
)
cur = conn.cursor()
for item in queries:
query = item['query']
description = item['description']
print(f"\nRunning query: {description}")
try:
cur.execute(query)
rows = cur.fetchall()
headers = [desc[0] for desc in cur.description]
print(f"{' | '.join(headers)}")
for row in rows:
print(f"{' | '.join(map(str, row))}")
except Exception as e:
print(f"Failed to run query: {e}")
conn.close()
except Exception as e:
print(f"Setup failed: {e}")
finally:
conn.close()

def pre_warm(config):
print(f"Running pre warm for database:{config['db-name']}")
try:
conn = psycopg2.connect(
dbname=config['db-name'],
user=config['username'],
password=config['password'],
host=config['host'],
)
cursor = conn.cursor()
cursor.execute("SELECT pg_prewarm('public.pgvector_index') as block_loaded")
conn.commit()

result = cursor.fetchone()
print(f"Pre-warm blocks loaded: {result[0]}")
conn.close()
except Exception as e:
print(f"Failed to pre-warm the database: {e}")

def teardown_database(config):
# Optionally drop the database after the test
pass
Expand Down Expand Up @@ -186,6 +237,9 @@ def run_benchmark(case, db_config, benchmark_description):
current_configs = query_configurations(db_config)
for key, value in current_configs.items():
print(f"{key}: {value}")
get_stats(db_config)
f.flush()
pre_warm(db_config)
print(f"Running command: {' '.join(command)}")
f.flush()

Expand All @@ -197,6 +251,9 @@ def run_benchmark(case, db_config, benchmark_description):
execution_time = end_time - start_time
print(f"total_duration={execution_time}")
print("***********END***********")
with redirect_stdout(f):
get_stats(db_config)
f.flush()
f.flush()
except subprocess.CalledProcessError as e:
print(f"Benchmark failed: {e}")
Expand Down
4 changes: 2 additions & 2 deletions run-scripts/run-hnsw-bq.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ def run_benchmark(case, db_config, benchmark_description):
else:
base_command.append("--skip-load")

if case.get("search_serial", True):
if case.get("search-serial", True):
base_command.append("--search-serial")
else:
base_command.append("--skip-search-serial")

if case.get("search_concurrent", True):
if case.get("search-concurrent", True):
base_command.append("--search-concurrent")
else:
base_command.append("--skip-search-concurrent")
Expand Down
Loading

0 comments on commit b0d2736

Please sign in to comment.