Skip to content

Commit

Permalink
chore(performance,tests): hybrid workload memory intensive test (#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
raftedproc authored Jan 22, 2024
1 parent 44407d2 commit 7554568
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
1 change: 1 addition & 0 deletions junk/gen-bench-data/gen_benchmark_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ for bench in multiple-cids10 \
canon-map-100mb \
call-result-100mb \
parser-air-100mb \
hybrid-100mb \
;
do
echo "Generating ${bench} ..." >&2
Expand Down
56 changes: 52 additions & 4 deletions junk/gen-bench-data/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ enum Bench {
CallResult100MB,
#[command(name = "parser-air-100mb")]
ParserAir100MB,
#[command(name = "hybrid-100mb")]
Hybrid100MB,
}

fn main() {
Expand Down Expand Up @@ -113,6 +115,7 @@ fn main() {
Bench::Map100MB => mem_consumption_w_map_2_scalar_with_size_in_mb(100),
Bench::CanonMap100MB => mem_consumption_w_canon_map_with_size_in_mb(100),
Bench::ParserAir100MB => mem_consumption_air_100mb(280000, 10),
Bench::Hybrid100MB => mem_consumption_hybrid_with_size_in_mb(100),
};

save_data(&args.dest_dir, data).unwrap();
Expand Down Expand Up @@ -802,7 +805,7 @@ fn mem_consumption_with_size_in_mb(data_size: usize) -> Data {
prev_data: vec![],
cur_data: prev_res.data,
params_json: hashmap! {
"comment".to_owned() => "benchmarking".to_owned(),
"comment".to_owned() => "Memory intensive benchmarking test".to_owned(),
"particle-id".to_owned() => PARTICLE_ID.to_owned(),
"current-peer-id".to_owned() => peer_id.clone(),
"init-peer-id".to_owned() => init_peer_id,
Expand Down Expand Up @@ -847,7 +850,7 @@ fn mem_consumption_w_lense_with_size_in_mb(data_size: usize) -> Data {
prev_data: vec![],
cur_data: prev_res.data,
params_json: hashmap! {
"comment".to_owned() => "benchmarking".to_owned(),
"comment".to_owned() => "Memory intensive benchmarking test with lense".to_owned(),
"particle-id".to_owned() => PARTICLE_ID.to_owned(),
"current-peer-id".to_owned() => peer_id.clone(),
"init-peer-id".to_owned() => init_peer_id,
Expand Down Expand Up @@ -892,7 +895,7 @@ fn mem_consumption_w_map_2_scalar_with_size_in_mb(data_size: usize) -> Data {
prev_data: vec![],
cur_data: prev_res.data,
params_json: hashmap! {
"comment".to_owned() => "benchmarking".to_owned(),
"comment".to_owned() => "Memory intensive benchmarking test with map 2 scalar".to_owned(),
"particle-id".to_owned() => PARTICLE_ID.to_owned(),
"current-peer-id".to_owned() => peer_id.clone(),
"init-peer-id".to_owned() => init_peer_id,
Expand Down Expand Up @@ -937,7 +940,52 @@ fn mem_consumption_w_canon_map_with_size_in_mb(data_size: usize) -> Data {
prev_data: vec![],
cur_data: prev_res.data,
params_json: hashmap! {
"comment".to_owned() => "benchmarking".to_owned(),
"comment".to_owned() => "Memory intensive benchmarking test with canon map".to_owned(),
"particle-id".to_owned() => PARTICLE_ID.to_owned(),
"current-peer-id".to_owned() => peer_id.clone(),
"init-peer-id".to_owned() => init_peer_id,
},
call_results: None,
keypair: bs58::encode(keypair.to_vec()).into_string(),
}
}

fn mem_consumption_hybrid_with_size_in_mb(data_size: usize) -> Data {
let random_data = generate_random_data(data_size);

let air_script = format!(
include_str!("mem_consumption_hybrid.air.tmpl"),
data = format_args!("{{\"attrib\": \"{}\"}}", hex::encode(random_data))
);

let exec = AirScriptExecutor::<NativeAirRunner>::new(
TestRunParameters::from_init_peer_id("init_peer_id").with_particle_id(PARTICLE_ID),
vec![],
vec![],
&air_script,
)
.unwrap();

let keypair = exec
.get_network()
.get_named_peer_env("other_peer_id")
.expect("main peer")
.borrow()
.get_peer()
.get_keypair()
.clone();

let prev_res = exec.execute_one("init_peer_id").unwrap();

let peer_id: String = exec.resolve_name("other_peer_id").to_string();
let init_peer_id: String = exec.resolve_name("init_peer_id").to_string();

Data {
air: exec.get_transformed_air_script().to_string(),
prev_data: vec![],
cur_data: prev_res.data,
params_json: hashmap! {
"comment".to_owned() => "Memory intensive benchmarking test with mixed workload".to_owned(),
"particle-id".to_owned() => PARTICLE_ID.to_owned(),
"current-peer-id".to_owned() => peer_id.clone(),
"init-peer-id".to_owned() => init_peer_id,
Expand Down
18 changes: 18 additions & 0 deletions junk/gen-bench-data/src/mem_consumption_hybrid.air.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(seq
(call "init_peer_id" ("" "init") [] data) ; ok = [{data}]
(seq
(seq
(fold data unused
(seq
(ap ("key" unused) %map)
(next unused)
)
)
(seq
(ap ("other" data.$.[0]) %map)
(canon "other_peer_id" %map new_data)
)
)
(canon "init_peer_id" $data #$data)
)
)

0 comments on commit 7554568

Please sign in to comment.