-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parallel tests #192
Merged
Ngalstyan4
merged 6 commits into
lanterndata:main
from
ezra-varady:ezra/parallel-testing
Oct 9, 2023
Merged
Add parallel tests #192
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c0cae0d
initial attempt at parallel test running in python
ezra-varady b666c4b
reimplement in pg_regress
ezra-varady 98d6e5e
initial implementation of parallel test running
ezra-varady d6c7da7
add some more tests clean things up
ezra-varady e95fe9d
merge test runner, integrate with CI correctly, add some notes about …
ezra-varady 3a9da81
make copies of common.sql for parallel tests and random_array.sql for…
ezra-varady File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
\ir utils/sift10k_array.sql | ||
CREATE TABLE IF NOT EXISTS sift_base10k ( | ||
id SERIAL PRIMARY KEY, | ||
v REAL[128] | ||
); | ||
\copy sift_base10k (v) FROM '/tmp/lantern/vector_datasets/siftsmall_base_arrays.csv' with csv; | ||
\ir utils/random_array.sql | ||
CREATE OR REPLACE FUNCTION random_int_array(dim integer, min integer, max integer) RETURNS integer[] AS $BODY$ | ||
begin | ||
return (select array_agg(round(random() * (max - min)) + min) from generate_series (0, dim - 1)); | ||
end | ||
$BODY$ LANGUAGE plpgsql; | ||
CREATE OR REPLACE FUNCTION random_array(dim integer, min real, max real) RETURNS REAL[] AS $BODY$ | ||
begin | ||
return (select array_agg(random() * (max - min) + min) from generate_series (0, dim - 1)); | ||
end | ||
$BODY$ LANGUAGE plpgsql; | ||
CREATE SEQUENCE serial START 10001; | ||
CREATE INDEX ON sift_base10k USING HNSW (v) WITH (M=5, ef=20, ef_construction=20); | ||
INFO: done init usearch index | ||
INFO: inserted 10000 elements | ||
INFO: done saving 10000 vectors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
SELECT COUNT(*) FROM sift_base10k; | ||
count | ||
------- | ||
10030 | ||
(1 row) | ||
|
||
SELECT * from sift_base10k WHERE id=4444; | ||
id | v | ||
------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
4444 | {55,61,11,4,5,2,13,24,65,49,13,9,23,37,94,38,54,11,14,14,40,31,50,44,53,4,0,0,27,17,8,34,12,10,4,4,22,52,68,53,9,2,0,0,2,116,119,64,119,2,0,0,2,30,119,119,116,5,0,8,47,9,5,60,7,7,10,23,56,50,23,5,28,68,6,18,24,65,50,9,119,75,3,0,1,8,12,85,119,11,4,6,8,9,5,74,25,11,8,20,18,12,2,21,11,90,25,32,33,15,2,9,84,67,8,4,22,31,11,33,119,30,3,6,0,0,0,26} | ||
(1 row) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
BEGIN; | ||
INSERT INTO sift_base10k (id, v) VALUES | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)); | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
BEGIN; | ||
INSERT INTO sift_base10k (id, v) VALUES | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)); | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
BEGIN; | ||
INSERT INTO sift_base10k (id, v) VALUES | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)); | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
SELECT v AS v1111 FROM sift_base10k WHERE id = 1111 \gset | ||
SELECT v AS v2222 FROM sift_base10k WHERE id = 2222 \gset | ||
SELECT v AS v3333 FROM sift_base10k WHERE id = 3333 \gset | ||
SELECT v AS v4444 FROM sift_base10k WHERE id = 4444 \gset | ||
SELECT id FROM sift_base10k ORDER BY v <-> :'v1111' ASC LIMIT 1; | ||
id | ||
------ | ||
1111 | ||
(1 row) | ||
|
||
SELECT id FROM sift_base10k ORDER BY v <-> :'v2222' ASC LIMIT 1; | ||
id | ||
------ | ||
2222 | ||
(1 row) | ||
|
||
SELECT id FROM sift_base10k ORDER BY v <-> :'v3333' ASC LIMIT 1; | ||
id | ||
------ | ||
3333 | ||
(1 row) | ||
|
||
SELECT id FROM sift_base10k ORDER BY v <-> :'v4444' ASC LIMIT 1; | ||
id | ||
------ | ||
4444 | ||
(1 row) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Get current test file name | ||
TESTFILE_NAME=${PGAPPNAME##pg_regress/} | ||
# Set different name for each test database | ||
# As pg_regress does not support cleaning db after each test | ||
var77 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
TEST_CASE_DB="ldb_parallel" | ||
# Set database user | ||
if [ -z $DB_USER ] | ||
then | ||
echo "ERROR: DB_USER environment variable is not set before test_runner.sh is run by pg_regress" | ||
exit 1 | ||
fi | ||
|
||
# Drop db after each test on exit signal | ||
function drop_db { | ||
cat <<EOF | psql "$@" -U ${DB_USER} -d postgres -v ECHO=none >/dev/null 2>&1 | ||
SET client_min_messages=ERROR; | ||
DROP DATABASE "${TEST_CASE_DB}"; | ||
EOF | ||
} | ||
|
||
if [[ "$TESTFILE_NAME" =~ ^end ]]; then | ||
var77 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
trap drop_db EXIT | ||
fi | ||
|
||
|
||
# Change directory to sql so sql imports will work correctly | ||
cd sql/ | ||
# install lantern extension | ||
if [[ "$TESTFILE_NAME" =~ ^begin ]]; then | ||
psql "$@" -U ${DB_USER} -d postgres -v ECHO=none -q -c "CREATE DATABASE ${TEST_CASE_DB};" 2>/dev/null | ||
psql "$@" -U ${DB_USER} -d ${TEST_CASE_DB} -v ECHO=none -q -c "SET client_min_messages=error; CREATE EXTENSION lantern;" 2>/dev/null | ||
#psql "$@" -U ${DB_USER} -d ${TEST_CASE_DB} -v ECHO=none -q -f utils/common.sql 2>/dev/null | ||
fi | ||
|
||
# Exclude debug/inconsistent output from psql | ||
var77 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# So tests will always have the same output | ||
psql -U ${DB_USER} \ | ||
-v ON_ERROR_STOP=1 \ | ||
-v VERBOSITY=terse \ | ||
-v ECHO=all \ | ||
"$@" -d ${TEST_CASE_DB} 2>&1 | \ | ||
sed -e 's! Memory: [0-9]\{1,\}kB!!' \ | ||
-e 's! Memory Usage: [0-9]\{1,\}kB!!' \ | ||
-e 's! Average Peak Memory: [0-9]\{1,\}kB!!' \ | ||
-e 's! time=[0-9]\+\.[0-9]\+\.\.[0-9]\+\.[0-9]\+!!' | \ | ||
grep -v 'DEBUG: rehashing catalog cache id' | \ | ||
grep -Gv '^ Planning Time:' | \ | ||
grep -Gv '^ Execution Time:' | \ | ||
# Only print debug messages followed by LANTERN | ||
perl -nle'print if !m{DEBUG:(?!.*LANTERN)}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
\ir utils/sift10k_array.sql | ||
\ir utils/random_array.sql | ||
|
||
CREATE SEQUENCE serial START 10001; | ||
CREATE INDEX ON sift_base10k USING HNSW (v) WITH (M=5, ef=20, ef_construction=20); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SELECT COUNT(*) FROM sift_base10k; | ||
SELECT * from sift_base10k WHERE id=4444; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
BEGIN; | ||
INSERT INTO sift_base10k (id, v) VALUES | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)); | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
BEGIN; | ||
INSERT INTO sift_base10k (id, v) VALUES | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)); | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
BEGIN; | ||
INSERT INTO sift_base10k (id, v) VALUES | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)), | ||
(nextval('serial'), random_array(128, 0, 128)); | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
SELECT v AS v1111 FROM sift_base10k WHERE id = 1111 \gset | ||
SELECT v AS v2222 FROM sift_base10k WHERE id = 2222 \gset | ||
SELECT v AS v3333 FROM sift_base10k WHERE id = 3333 \gset | ||
SELECT v AS v4444 FROM sift_base10k WHERE id = 4444 \gset | ||
SELECT id FROM sift_base10k ORDER BY v <-> :'v1111' ASC LIMIT 1; | ||
SELECT id FROM sift_base10k ORDER BY v <-> :'v2222' ASC LIMIT 1; | ||
var77 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SELECT id FROM sift_base10k ORDER BY v <-> :'v3333' ASC LIMIT 1; | ||
SELECT id FROM sift_base10k ORDER BY v <-> :'v4444' ASC LIMIT 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE OR REPLACE FUNCTION random_int_array(dim integer, min integer, max integer) RETURNS integer[] AS $BODY$ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like this would be useful in regular tests as well. Should be in the utils for regular tests. |
||
begin | ||
return (select array_agg(round(random() * (max - min)) + min) from generate_series (0, dim - 1)); | ||
end | ||
$BODY$ LANGUAGE plpgsql; | ||
|
||
CREATE OR REPLACE FUNCTION random_array(dim integer, min real, max real) RETURNS REAL[] AS $BODY$ | ||
begin | ||
return (select array_agg(random() * (max - min) + min) from generate_series (0, dim - 1)); | ||
end | ||
$BODY$ LANGUAGE plpgsql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE TABLE IF NOT EXISTS sift_base10k ( | ||
id SERIAL PRIMARY KEY, | ||
v REAL[128] | ||
); | ||
\copy sift_base10k (v) FROM '/tmp/lantern/vector_datasets/siftsmall_base_arrays.csv' with csv; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# schedule.txt rules: | ||
# - every test that needs to be run must appear in a 'test:' line | ||
# - every test that needs to be run iff pgvector is installed appears in a 'test_pgvector:' line | ||
# - 'test' lines may have multiple space-separated tests. All tests in a single 'test' line will be run in parallel | ||
|
||
test_begin: begin | ||
test: insert insert2 insert3 select | ||
test_end: end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this PR, but still important: Do we currently run pgvector compat tests anywhere in ci/cd or release pipeline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we are running them in the pipeline, as we're installing the pgvector there