Skip to content

Commit

Permalink
More versions of by name for benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiemo Bang committed Jul 12, 2024
1 parent 2cb8cb0 commit 520820c
Show file tree
Hide file tree
Showing 25 changed files with 5,863 additions and 611 deletions.
533 changes: 244 additions & 289 deletions incremental_transactions/tpcc/benches/byname.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion incremental_transactions/tpcc/benches/byname_max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn byname(c: &mut Criterion) {
let num_workers = 1;
// Input the initial size of the customer relation and the number of updates
let base_size = 3000; // Number of customers per district
let update_sizes = vec![1, 2, 4, 8, 16, 32, 64, 128, 256, 512];
let update_sizes = vec![0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512];
let inputs: Vec<_> = update_sizes
.into_iter()
.map(|updates_size| ExperimentInput {
Expand Down
18 changes: 14 additions & 4 deletions incremental_transactions/tpcc/generate_dbsp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ compile() {
# Concatenate the schema and payment files on the fly and hand to the compiler
args="--alltables --handles ${DO_INCREMENTAL}"
${SQL_COMPILER} <(cat "${SCHEMA}" "${VIEWS_FILE}") ${args} -o ${OUTPUT}
# Check if the compiler failed and exit
if [ $? -ne 0 ]; then
echo "Compilation failed"
exit 1
fi
# Remove the allocator code from the output
remove_allocator "${OUTPUT}"

Expand All @@ -64,9 +69,14 @@ compile() {

# compile "${THIS_ABS_DIR}/sql/payment.sql" "${THIS_ABS_DIR}/src/payment_sql.rs" 0 1
# compile "${THIS_ABS_DIR}/sql/payment.sql" "${THIS_ABS_DIR}/src/payment_sql_incremental.rs" 1 1
compile "${THIS_ABS_DIR}/sql/byname.sql" "${THIS_ABS_DIR}/src/byname_sql.rs" 0 1
compile "${THIS_ABS_DIR}/sql/byname.sql" "${THIS_ABS_DIR}/src/byname_sql_incremental.rs" 1 1
compile "${THIS_ABS_DIR}/sql/byname_max.sql" "${THIS_ABS_DIR}/src/byname_max_sql.rs" 0 1
compile "${THIS_ABS_DIR}/sql/byname_max.sql" "${THIS_ABS_DIR}/src/byname_max_sql_incremental.rs" 1 1
#compile "${THIS_ABS_DIR}/sql/byname.sql" "${THIS_ABS_DIR}/src/byname_sql.rs" 0 1
#compile "${THIS_ABS_DIR}/sql/byname.sql" "${THIS_ABS_DIR}/src/byname_sql_incremental.rs" 1 1
#compile "${THIS_ABS_DIR}/sql/byname_constargs.sql" "${THIS_ABS_DIR}/src/byname_sql_constargs.rs" 0 1
#compile "${THIS_ABS_DIR}/sql/byname_constargs_inlined.sql" "${THIS_ABS_DIR}/src/byname_sql_constargs_inlined.rs" 0 1
compile "${THIS_ABS_DIR}/sql/byname_constargs_inlined_minimized.sql" "${THIS_ABS_DIR}/src/byname_sql_incremental_constargs_inlined_minimized.rs" 1 1
#compile "${THIS_ABS_DIR}/sql/byname_constargs.sql" "${THIS_ABS_DIR}/src/byname_sql_incremental_constargs.rs" 1 1
#compile "${THIS_ABS_DIR}/sql/byname_constargs_inlined.sql" "${THIS_ABS_DIR}/src/byname_sql_incremental_constargs_inlined.rs" 1 1
#compile "${THIS_ABS_DIR}/sql/byname_max.sql" "${THIS_ABS_DIR}/src/byname_max_sql.rs" 0 1
#compile "${THIS_ABS_DIR}/sql/byname_max.sql" "${THIS_ABS_DIR}/src/byname_max_sql_incremental.rs" 1 1
#compile "${THIS_ABS_DIR}/sql/warehouse_ytd.sql" "${THIS_ABS_DIR}/src/warehouse_ytd_sql.rs" 0 1
#compile "${THIS_ABS_DIR}/sql/warehouse_ytd.sql" "${THIS_ABS_DIR}/src/warehouse_ytd_sql_incremental.rs" 1 1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(in_warehouse_static, in_warehouse, in_district_static, in_district_next_id, in_district_ytd, in_customer, in_transaction_parameters, out_cust_agg, out_cust_byname)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(in_warehouse_static, in_warehouse, in_district_static, in_district_next_id, in_district_ytd, in_customer, in_transaction_parameters, out_cust_byname_inlined)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(in_warehouse_static, in_warehouse, in_district_static, in_district_next_id, in_district_ytd, in_customer, in_transaction_parameters, out_cust_agg, out_cust_byname)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(in_warehouse_static, in_warehouse, in_district_static, in_district_next_id, in_district_ytd, in_customer, in_transaction_parameters, out_cust_byname_inlined)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(in_warehouse_static, in_warehouse, in_district_static, in_district_next_id, in_district_ytd, in_customer, in_transaction_parameters, out_cust_byname_inlined_minimized, out_cust_byname_inlined)
17 changes: 17 additions & 0 deletions incremental_transactions/tpcc/sql/byname_constargs.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE VIEW cust_agg AS
SELECT ARRAY_AGG((c_id + c_w_id + c_d_id) ORDER BY c_first) AS cust_array
FROM (SELECT c.c_id, c.c_w_id, c.c_d_id, c.c_first
FROM customer AS c
WHERE c.c_last = 'lastname'
AND c.c_d_id = 43
AND c.c_w_id = 44
ORDER BY c_first);

CREATE VIEW cust_byname AS
SELECT c.c_first, c.c_middle, c.c_id,
c.c_street_1, c.c_street_2, c.c_city, c.c_state, c.c_zip,
c.c_phone, c.c_credit, c.c_credit_lim,
c.c_discount, c.c_balance, c.c_since
FROM customer as c,
cust_agg as a
WHERE (c.c_id + c.c_w_id + c.c_d_id) = a.cust_array[(ARRAY_LENGTH(a.cust_array) / 2) + 1];
14 changes: 14 additions & 0 deletions incremental_transactions/tpcc/sql/byname_constargs_inlined.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE VIEW cust_byname_inlined AS
SELECT c.c_first, c.c_middle, c.c_id,
c.c_street_1, c.c_street_2, c.c_city, c.c_state, c.c_zip,
c.c_phone, c.c_credit, c.c_credit_lim,
c.c_discount, c.c_balance, c.c_since
FROM customer as c,
(SELECT ARRAY_AGG((c_id + c_w_id + c_d_id) ORDER BY c_first) AS cust_array
FROM (SELECT c.c_id, c.c_w_id, c.c_d_id, c.c_first
FROM customer AS c
WHERE c.c_last = 'lastname'
AND c.c_d_id = 43
AND c.c_w_id = 44
ORDER BY c_first)) as a
WHERE (c.c_id + c.c_w_id + c.c_d_id) = a.cust_array[(ARRAY_LENGTH(a.cust_array) / 2) + 1];
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CREATE VIEW cust_byname_inlined_minimized AS
SELECT a.cust_array[(ARRAY_LENGTH(a.cust_array) / 2) + 1] FROM
(SELECT ARRAY_AGG((c_first) ORDER BY c_first) AS cust_array
FROM (SELECT c.c_id, c.c_w_id, c.c_d_id, c.c_first
FROM customer AS c
WHERE c.c_last = 'lastname'
AND c.c_d_id = 43
AND c.c_w_id = 44
ORDER BY c_first)) as a

--CREATE VIEW cust_byname_inlined AS
/* SELECT c.c_first, c.c_middle, c.c_id,
c.c_street_1, c.c_street_2, c.c_city, c.c_state, c.c_zip,
c.c_phone, c.c_credit, c.c_credit_lim,
c.c_discount, c.c_balance, c.c_since
FROM customer as c,
(SELECT ARRAY_AGG((c_id + c_w_id + c_d_id) ORDER BY c_first) AS cust_array
FROM (SELECT c.c_id, c.c_w_id, c.c_d_id, c.c_first
FROM customer AS c
WHERE c.c_last = 'lastname'
AND c.c_d_id = 43
AND c.c_w_id = 44
ORDER BY c_first)) as a
WHERE (c.c_id + c.c_w_id + c.c_d_id) = a.cust_array[(ARRAY_LENGTH(a.cust_array) / 2) + 1];
*/
24 changes: 24 additions & 0 deletions incremental_transactions/tpcc/sql/stock_level.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
EXEC SQL SELECT d_next_o_id INTO :o_id
FROM district
WHERE d_w_id=:w_id AND d_id=:d_id;
EXEC SQL SELECT COUNT(DISTINCT (s_i_id)) INTO :stock_count
FROM order_line, stock
WHERE ol_w_id=:w_id AND
ol_d_id=:d_id AND ol_o_id<:o_id AND
ol_o_id>=:o_id-20 AND s_w_id=:w_id AND
s_i_id=ol_i_id AND s_quantity < :threshold;
*/


SELECT d_next_o_id AS o_id_max, d_next_o_id-20 AS o_id_min
FROM district
WHERE d_w_id=:w_id AND d_id=:d_id;

CREATE VIEW stock_level_district AS
SELECT COUNT(DISTINCT (s_i_id)) AS stock_count
FROM order_line, stock
WHERE ol_w_id=44 AND -- set warehouse here
ol_d_id=43 AND ol_o_id<o_id_max AND -- set district here
ol_o_id>=o_id_min AND s_w_id=44 AND -- set warehouse here
s_i_id=ol_i_id AND s_quantity < 100; -- set threshold here
Loading

0 comments on commit 520820c

Please sign in to comment.