Skip to content

Commit 05ea7cd

Browse files
committed
WIP
1 parent 615501d commit 05ea7cd

File tree

11 files changed

+223
-95
lines changed

11 files changed

+223
-95
lines changed

.github/actions/setup-rust/action.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Setup Test
2+
description: |
3+
This action sets up the environment for running tests in a Rust project.
4+
It installs Rust, sets up caching, and installs mise.
5+
6+
runs:
7+
using: composite
8+
steps:
9+
- uses: actions/checkout@v4
10+
- name: Install rust
11+
shell: /bin/bash -l {0}
12+
run: rustup toolchain install stable --profile minimal --no-self-update
13+
- name: Setup Rust cache
14+
uses: Swatinem/rust-cache@v2
15+
with:
16+
cache-provider: buildjet
17+
cache-all-crates: true
18+
- uses: jdx/mise-action@v2
19+
with:
20+
version: 2025.1.0 # [default: latest] mise version to install
21+
install: true # [default: true] run `mise install`
22+
cache: true # [default: true] cache mise using GitHub's cache

.github/workflows/benchmark.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Benchmark Proxy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
8+
permissions:
9+
# deployments permission to deploy GitHub pages website
10+
deployments: write
11+
# contents permission to update benchmark contents in gh-pages branch
12+
contents: write
13+
14+
jobs:
15+
benchmark:
16+
name: Performance regression check
17+
runs-on: buildjet-16vcpu-ubuntu-2204
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: ./.github/actions/setup-test
21+
22+
# Run benchmark with `go test -bench` and stores the output to a file
23+
- name: Run benchmark
24+
run: mise run benchmark:continuous
25+
26+
27+
# Download previous benchmark result from cache (if exists)
28+
- name: Download previous benchmark data
29+
uses: actions/cache@v4
30+
with:
31+
path: ./cache
32+
key: ${{ runner.os }}-benchmark
33+
# Run `github-action-benchmark` action
34+
- name: Store benchmark result
35+
uses: benchmark-action/github-action-benchmark@v1
36+
with:
37+
# What benchmark tool the output.txt came from
38+
tool: 'pgbench'
39+
# Where the output from the benchmark tool is stored
40+
output-file-path: tests/benchmarks/results/output.txt
41+
# Where the previous data file is stored
42+
external-data-json-path: ./cache/benchmark-data.json
43+
# Workflow will fail when an alert happens
44+
fail-on-alert: true
45+
# Enable alert commit comment
46+
comment-on-alert: true
47+
# GitHub API token to make a commit comment
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
# Enable Job Summary for PRs
50+
summary-always: true
51+
auto-push: true

.github/workflows/test.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,7 @@ jobs:
1616
runs-on: buildjet-16vcpu-ubuntu-2204
1717
steps:
1818
- uses: actions/checkout@v4
19-
- name: Install rust
20-
shell: /bin/bash -l {0}
21-
run: rustup toolchain install stable --profile minimal --no-self-update
22-
- name: Setup Rust cache
23-
uses: Swatinem/rust-cache@v2
24-
with:
25-
cache-provider: buildjet
26-
cache-all-crates: true
27-
- uses: jdx/mise-action@v2
28-
with:
29-
version: 2025.1.0 # [default: latest] mise version to install
30-
install: true # [default: true] run `mise install`
31-
cache: true # [default: true] cache mise using GitHub's cache
19+
- uses: ./.github/actions/setup-test
3220
- run: |
3321
mise run postgres:up --extra-args "--detach --wait"
3422
- env:

Cargo.toml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ edition = "2021"
1010
incremental = true
1111
debug = true
1212

13+
# [profile.dev.package]# aws-lc-sys.opt-level = 3
14+
# proc-macro2.opt-level = 3
15+
# quote.opt-level = 3
16+
# serde_derive.opt-level = 3
17+
# sqlparser.opt-level = 3
18+
# syn.opt-level = 3
19+
1320
[profile.dev.build-override]
1421
opt-level = 3
1522

@@ -20,7 +27,25 @@ debug = true
2027
[profile.release]
2128
codegen-units = 1
2229
strip = "symbols"
23-
lto = true
30+
31+
# Default release profile (https://doc.rust-lang.org/cargo/reference/profiles.html)
32+
# [profile.release]
33+
# opt-level = 3
34+
# debug = false
35+
# split-debuginfo = '...' # Platform-specific.
36+
# strip = "none"
37+
# debug-assertions = false
38+
# overflow-checks = false
39+
# lto = false
40+
# panic = 'unwind'
41+
# incremental = false
42+
# codegen-units = 16
43+
# rpath = false
44+
45+
[profile.profiling]
46+
inherits = "release"
47+
strip = "none"
48+
debug = true
2449

2550
[workspace.dependencies]
2651
sqlparser = { version = "^0.52", features = ["bigdecimal", "serde"] }

packages/cipherstash-proxy/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ uuid = { version = "1.11.0", features = ["serde", "v4"] }
5656
x509-parser = "0.17.0"
5757
vitaminc-protected = "0.1.0-pre2"
5858

59+
# [target.'cfg(not(target_env = "msvc"))'.dependencies]
60+
# jemallocator = "0.5.4"
5961

6062
[dev-dependencies]
6163
recipher = "0.1.3"

packages/cipherstash-proxy/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ use tokio::signal::unix::{signal, SignalKind};
1111
use tokio_util::task::TaskTracker;
1212
use tracing::{error, info, warn};
1313

14+
// #[cfg(not(target_env = "msvc"))]
15+
// use jemallocator::Jemalloc;
16+
17+
// #[cfg(not(target_env = "msvc"))]
18+
// #[global_allocator]
19+
// static GLOBAL: Jemalloc = Jemalloc;
20+
1421
const EQL_VERSION_AT_BUILD_TIME: Option<&'static str> = option_env!("EQL_VERSION_AT_BUILD_TIME");
1522

1623
fn main() -> Result<(), Box<dyn std::error::Error>> {

tests/benchmark/mise.toml

Lines changed: 100 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ includes = ["./tasks"]
77

88

99
[env]
10-
CS_DATABASE__HOST = "host.docker.internal"
10+
1111
POSTGRES_DB = "{{env.CS_DATABASE__NAME}}"
1212
PGUSER = "{{env.CS_DATABASE__USERNAME}}"
1313
PGPASSWORD = "{{env.CS_DATABASE__PASSWORD}}"
@@ -16,6 +16,48 @@ PGPORT = "{{env.CS_DATABASE__PORT}}"
1616

1717
# ====================================================================================================
1818

19+
[tasks."benchmark:continuous"]
20+
description = "Run proxy encryption benchmark for CI"
21+
run = """
22+
set -e
23+
mise run benchmark:clean
24+
25+
set -e
26+
27+
echo
28+
echo '###############################################'
29+
echo '# Preflight'
30+
echo '###############################################'
31+
echo
32+
33+
# Ensure Postgres instances are running
34+
mise run test:integration:preflight
35+
36+
echo
37+
echo '###############################################'
38+
echo '# Setup'
39+
echo '###############################################'
40+
echo
41+
42+
# Ensure EQL is set up before we try and start Proxy
43+
mise --env tcp run postgres:setup
44+
45+
mise run benchmark:setup
46+
47+
mise --env tcp run proxy:up proxy --extra-args "--detach --wait"
48+
mise --env tcp run test:wait_for_postgres_to_quack --port 6432 --max-retries 20
49+
50+
echo
51+
echo '###############################################'
52+
echo '# Extended protocol with encrypted transaction'
53+
echo '###############################################'
54+
echo
55+
56+
# Extended protocol with encrypted script
57+
mise run benchmark_service --target=proxy --transaction=encrypted --protocol=extended --port=6432 --time=30 --clients=10
58+
"""
59+
60+
1961
[tasks."benchmark"]
2062
alias = 'b'
2163
description = "Run benchmarks"
@@ -24,21 +66,72 @@ set -e
2466
2567
mise run benchmark:clean
2668
69+
set -e
70+
71+
echo
72+
echo '###############################################'
73+
echo '# Preflight'
74+
echo '###############################################'
75+
echo
76+
77+
# Ensure Postgres instances are running
78+
mise run test:integration:preflight
79+
80+
echo
81+
echo '###############################################'
82+
echo '# Setup'
83+
echo '###############################################'
84+
echo
85+
86+
# Ensure EQL is set up before we try and start Proxy
87+
mise --env tcp run postgres:setup
88+
2789
mise run benchmark:setup
2890
91+
mise --env tcp run pgbouncer:up --extra-args "--detach --wait"
92+
mise --env tcp run proxy:up proxy --extra-args "--detach --wait"
93+
mise --env tcp run test:wait_for_postgres_to_quack --port 6432 --max-retries 20
94+
95+
96+
echo
97+
echo '###############################################'
98+
echo '# Extended protocol with default pgbench transaction'
99+
echo '###############################################'
100+
echo
101+
29102
# # Extended protocol with default script
30-
# mise run benchmark_service --target=postgres --protocol=extended --port=5532 --time=5
31-
# mise run benchmark_service --target=pgbouncer --protocol=extended --port=6433 --time=5
32-
# mise run benchmark_service --target=proxy --protocol=extended --port=6432 --time=5
103+
mise run benchmark_service --target=postgres --protocol=extended --port=5532 --time=5
104+
mise run benchmark_service --target=pgbouncer --protocol=extended --port=6433 --time=5
105+
mise run benchmark_service --target=proxy --protocol=extended --port=6432 --time=5
106+
107+
108+
echo
109+
echo '###############################################'
110+
echo '# Extended protocol with plaintext transaction'
111+
echo '###############################################'
112+
echo
33113
34-
# Extended protocol with plaintext script
35114
mise run benchmark_service --target=postgres --transaction=plaintext --protocol=extended --port=5532 --time=5
36115
mise run benchmark_service --target=pgbouncer --transaction=plaintext --protocol=extended --port=6433 --time=5
37116
mise run benchmark_service --target=proxy --transaction=plaintext --protocol=extended --port=6432 --time=5
38117
118+
119+
echo
120+
echo '###############################################'
121+
echo '# Extended protocol with encrypted transaction'
122+
echo '###############################################'
123+
echo
124+
39125
# Extended protocol with encrypted script
40126
mise run benchmark_service --target=proxy --transaction=encrypted --protocol=extended --port=6432 --time=5
41127
128+
129+
echo
130+
echo '###############################################'
131+
echo '# Process results'
132+
echo '###############################################'
133+
echo
134+
42135
mise run benchmark:plot
43136
"""
44137

@@ -47,7 +140,7 @@ run = """
47140
cat sql/benchmark-schema.sql | docker exec -i postgres${CONTAINER_SUFFIX} psql postgresql://${CS_DATABASE__USERNAME}:${CS_DATABASE__PASSWORD}@${CS_DATABASE__HOST}:${CS_DATABASE__PORT}/${CS_DATABASE__NAME} -f-
48141
49142
# Initialize pgbench
50-
docker compose run --rm postgres${CONTAINER_SUFFIX:-} pgbench --host=${CS_DATABASE__HOST} --port=${CS_DATABASE__PORT} --scale=1 -i --no-vacuum
143+
docker compose run --rm postgres${CONTAINER_SUFFIX:-} pgbench --host=host.docker.internal --port=${CS_DATABASE__PORT} --scale=1 -i --no-vacuum
51144
"""
52145

53146
[tasks."benchmark:plot"]
@@ -57,18 +150,6 @@ run = """
57150
python plot.py
58151
"""
59152

60-
[tasks."benchmark:up"]
61-
alias = 'u'
62-
description = "Run PostgreSQL with docker compose"
63-
run = """
64-
set -e
65-
66-
mise run postgres:up
67-
mise run pgbouncer:up
68-
mise run proxy:up
69-
70-
"""
71-
72153
[tasks."benchmark:clean"]
73154
description = "Clean old benchmark results"
74155
run = """
@@ -80,50 +161,5 @@ alias = 'u'
80161
description = "Run pgbouncer"
81162
run = """
82163
set -e
83-
docker compose up --build pgbouncer --detach
164+
echo docker compose up --build {{arg(name="service",default="pgbouncer")}} {{option(name="extra-args",default="")}} | bash
84165
"""
85-
86-
87-
# [tasks."down"]
88-
# alias = 'u'
89-
# description = "Tear down PostgreSQL and Proxy containers"
90-
# run = """
91-
# set -e
92-
# if [[ -z "${CS_BENCHMARK_BUILD}" ]]; then
93-
# mise run proxy:down
94-
# mise run postgres:down
95-
# fi
96-
# """
97-
98-
# [tasks."proxy:up"]
99-
# alias = 'u'
100-
# description = "Run CipherStash Proxy with docker compose"
101-
# run = """
102-
# set -e
103-
104-
# docker compose up --build proxy --detach
105-
# """
106-
107-
# [tasks."proxy:down"]
108-
# alias = 'pd'
109-
# description = "Tear down Proxy container"
110-
# run = """
111-
# set -e
112-
# docker compose down proxy
113-
# """
114-
115-
# [tasks."postgres:up"]
116-
# alias = 'pgu'
117-
# description = "Run PostgreSQL with docker compose"
118-
# run = """
119-
# set -e
120-
# docker compose up postgres --detach
121-
# """
122-
123-
# [tasks."postgres:down"]
124-
# alias = 'pgd'
125-
# description = "Tear down PostgreSQL container"
126-
# run = """
127-
# set -e
128-
# docker compose down postgres
129-
# """

0 commit comments

Comments
 (0)