Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion templates/keynote-2/DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ From `src/cli.ts`:

- **`--alpha A`**
- Zipf α parameter for account selection (hot vs cold distribution)
- Default: `0.5`
- Default: `1.5`

- **`--connectors list`**
- Optional, comma-separated list of connector `system` names
Expand Down
2 changes: 1 addition & 1 deletion templates/keynote-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ docker compose up -d pg crdb
npm run prep

# Run benchmark
npm run bench -- --seconds 10 --concurrency 50 --alpha 0 --connectors spacetimedb,postgres_rpc,sqlite_rpc
npm run bench -- --seconds 10 --concurrency 50 --alpha 1.5 --connectors spacetimedb,postgres_rpc,sqlite_rpc
```

## Output
Expand Down
2 changes: 1 addition & 1 deletion templates/keynote-2/docker-compose-linux-raid-crdb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
volumes:
- /mnt/local-ssd/sqlite_data:/data
- ./runs:/app/runs
command: ["--seconds", "5", "--concurrency", "50", "--alpha", "1", "--connectors", "sqlite"]
command: ["--seconds", "5", "--concurrency", "50", "--alpha", "1.5", "--connectors", "sqlite"]
network_mode: host

sqlite-seed:
Expand Down
2 changes: 1 addition & 1 deletion templates/keynote-2/docker-compose-linux-raid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
volumes:
- /mnt/local-ssd/sqlite_data:/data
- ./runs:/app/runs
command: ["--seconds", "5", "--concurrency", "50", "--alpha", "1", "--connectors", "sqlite"]
command: ["--seconds", "5", "--concurrency", "50", "--alpha", "1.5", "--connectors", "sqlite"]
network_mode: host

sqlite-seed:
Expand Down
2 changes: 1 addition & 1 deletion templates/keynote-2/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
volumes:
- sqlite_data:/data
- ./runs:/app/runs
command: ["--seconds", "5", "--concurrency", "50", "--alpha", "1", "--connectors", "sqlite"]
command: ["--seconds", "5", "--concurrency", "50", "--alpha", "1.5", "--connectors", "sqlite"]
network_mode: host

sqlite-seed:
Expand Down
29 changes: 7 additions & 22 deletions templates/keynote-2/spacetimedb-rust-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ const LOCALHOST: &str = "http://localhost:3000";
const MODULE: &str = "sim";

const DURATION: &str = "5s";
const WARMUP_DURATION: &str = "5s";
const ALPHA: f32 = 0.5;
const ALPHA: f32 = 1.5;
const CONNECTIONS: usize = 10;
const INIT_BALANCE: i64 = 1_000_000;
const AMOUNT: u32 = 1;
const ACCOUNTS: u32 = 100_000;
const CONFIRMED_READS: bool = false;
const CONFIRMED_READS: bool = true;
// Max inflight reducer calls imposed by the server.
const MAX_INFLIGHT_REDUCERS: u64 = 16384;

Expand Down Expand Up @@ -139,9 +138,11 @@ fn bench(cli: &Common, bench: &Bench) {
println!();
}

// Parse the durations.
// Parse the duration.
let duration = parse_duration(&bench.duration).expect("invalid duration passed");
let warmup_duration = parse_duration(&bench.warmup_duration).expect("invalid warmup duration passed");
if !cli.quiet {
eprintln!("benchmarking for {}...", format_duration(duration));
}

// Initialize connections.
let connections = bench.connections;
Expand All @@ -160,15 +161,10 @@ fn bench(cli: &Common, bench: &Bench) {
let transfer_pairs = &make_transfers(accounts, alpha);
let transfers_per_worker = transfer_pairs.len() / conns.len();

let warmup_start_all = Instant::now();
let mut start_all = warmup_start_all;
let barrier = &std::sync::Barrier::new(conns.len());
let mut start_all = Instant::now();
let completed = Arc::new(AtomicU64::default());

thread::scope(|scope| {
if !cli.quiet {
eprintln!("warming up for {}...", format_duration(warmup_duration));
}
let mut start_all = Some(&mut start_all);
for (worker_idx, (mut rx, tx)) in conns.into_iter().enumerate() {
let completed = completed.clone();
Expand Down Expand Up @@ -214,14 +210,6 @@ fn bench(cli: &Common, bench: &Bench) {
transfers
};

while warmup_start_all.elapsed() < warmup_duration {
run();
}

if barrier.wait().is_leader() && !cli.quiet {
eprintln!("finished warmup...");
eprintln!("benchmarking for {}...", format_duration(duration));
}
let start = Instant::now();
if let Some(start_all) = start_all {
*start_all = start;
Expand Down Expand Up @@ -315,9 +303,6 @@ struct Bench {
#[arg(short, long, default_value = DURATION)]
duration: String,

#[arg(short, long, default_value = WARMUP_DURATION)]
warmup_duration: String,

#[arg(short, long)]
tps_write_path: Option<String>,
}
Expand Down
6 changes: 3 additions & 3 deletions templates/keynote-2/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let seconds = 1,
accounts = process.env.SEED_ACCOUNTS
? Number(process.env.SEED_ACCOUNTS)
: 100_000,
alpha = 0.5,
alpha = 1.5,
connectors: string[] | null = null,
contentionTests: {
startAlpha: number;
Expand Down Expand Up @@ -173,7 +173,7 @@ class BenchmarkTester {
startConc: number = 1,
endConc: number = 100,
step: number = 1,
alpha: number = 1,
alpha: number = 1.5,
) {
const results: { concurrency: number; avgResult: RunResult }[] = [];
for (let conc = startConc; conc <= endConc; conc += step) {
Expand All @@ -189,7 +189,7 @@ class BenchmarkTester {
startConc: number = 1,
endConc: number = 100,
factor: number = 2,
alpha: number = 1,
alpha: number = 1.5,
) {
if (factor <= 1) {
throw new Error('factor must be > 1 to avoid infinite loop');
Expand Down
2 changes: 1 addition & 1 deletion templates/keynote-2/src/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function hasFlag(name: string): boolean {

const seconds = getArg('seconds', 10);
const concurrency = getArg('concurrency', 10);
const alpha = getArg('alpha', 0.5);
const alpha = getArg('alpha', 1.5);
const systems = getStringArg('systems', 'convex,spacetimedb')
.split(',')
.map((s) => s.trim());
Expand Down
Loading