Skip to content

Commit

Permalink
Add a new function to loadgen contract for apply load testing.
Browse files Browse the repository at this point in the history
This function avoids accessing storage as that's not necessary for covering I/O (storage is just an in-memory map on the host side). It also emits events.

Also cleaned up the build configs of the examples.
  • Loading branch information
dmkozh committed Nov 8, 2024
1 parent 05219cf commit 2d63bfe
Show file tree
Hide file tree
Showing 36 changed files with 87 additions and 390 deletions.
340 changes: 66 additions & 274 deletions soroban-test-wasms/wasm-workspace/Cargo.lock

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/add_f32/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/add_i32/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true, features = ["alloc"] }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/complex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
1 change: 0 additions & 1 deletion soroban-test-wasms/wasm-workspace/constructor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }
5 changes: 0 additions & 5 deletions soroban-test-wasms/wasm-workspace/contract_data/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
testutils = ["soroban-sdk/testutils"]
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/create_contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
1 change: 0 additions & 1 deletion soroban-test-wasms/wasm-workspace/deployer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/err/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/fannkuch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/fib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/hostile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/invoke_contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/linear_memory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/loadgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
22 changes: 21 additions & 1 deletion soroban-test-wasms/wasm-workspace/loadgen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![no_std]
use soroban_sdk::{contract, contractimpl, Bytes, Env, U256};
use soroban_sdk::{contract, contractimpl, symbol_short, Bytes, Env, U256};

#[contract]
pub struct Contract;
Expand Down Expand Up @@ -48,4 +48,24 @@ impl Contract {
// Return has data dependency on both values to make sure nothing gets optimized out
u256_val
}

pub fn do_cpu_only_work(e: Env, guest_cycles: u32, host_cycles: u32, event_count: u32) -> U256 {
let mut val: i64 = 3;
for _ in 0..guest_cycles {
val = (val * 1664525 + 1013904223) >> 32;
}

let mut u256_val = U256::from_u32(&e, val as u32);
let u256_1 = U256::from_u32(&e, 1);
for _ in 0..host_cycles {
u256_val = u256_val.add(&u256_1);
}

for _ in 0..event_count {
e.events().publish((symbol_short!("event"),), val);
}

// Return has data dependency on both values to make sure nothing gets optimized out
u256_val
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }
Binary file modified soroban-test-wasms/wasm-workspace/opt/20/loadgen.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/simple_account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/sum_i32/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/update/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/upload_contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
4 changes: 0 additions & 4 deletions soroban-test-wasms/wasm-workspace/vec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ doctest = false

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]

0 comments on commit 2d63bfe

Please sign in to comment.