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
23 changes: 5 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ members = [
# The order matches with publishing order.
sails-idl-meta = { path = "rs/idl-meta" }
sails-idl-parser = { path = "rs/idl-parser" }
sails-idl-parser-v2 = { path = "rs/idl-parser-v2" }
sails-idl-parser-v2 = { path = "rs/idl-parser-v2", default-features = false }
sails-idl-gen = { path = "rs/idl-gen" }
sails-client-gen = { path = "rs/client-gen" }
sails-macros-core = { path = "rs/macros/core" }
Expand All @@ -75,7 +75,7 @@ gwasm-builder = { version = "=1.9.2", package = "gear-wasm-builder" }
alloy-primitives = { version = "0.8.19", default-features = false }
alloy-sol-types = { version = "0.8.19", default-features = false }
anyhow = "1"
askama = "0.14"
askama = { version = "0.14", default-features = false }
cargo-generate = "0.23"
cargo_metadata = "0.19"
clap = "4.5"
Expand Down
36 changes: 18 additions & 18 deletions benchmarks/bench_data.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"compute": {
"median": 450513692764
"median": 450514036959
},
"alloc": {
"0": 563797174,
"12": 567303766,
"143": 726672361,
"986": 827658128,
"10945": 2018422654,
"46367": 6403684137,
"121392": 16858375895,
"317810": 43146695232
"0": 564376739,
"12": 567864696,
"143": 727298127,
"986": 828290311,
"10945": 2019067671,
"46367": 6404351520,
"121392": 16859084038,
"317810": 43147409792
},
"counter": {
"async_call": 850478213,
"sync_call": 677855029
"async_call": 851480134,
"sync_call": 678859589
},
"cross_program": {
"median": 2433669984
"median": 2437527818
},
"redirect": {
"median": 3469451691
"median": 3474613683
},
"message_stack": {
"0": 797238065,
"1": 3762055850,
"5": 15662630147,
"10": 29532802161,
"20": 63872681625
"0": 799115685,
"1": 3769584063,
"5": 15693086906,
"10": 29592077575,
"20": 63989367411
}
}
22 changes: 12 additions & 10 deletions benchmarks/idls/alloc_stress_program.idl
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
program AllocStress {
constructors {
NewForBench();
}
services {
AllocStress,
!@sails: 0.9.2

service AllocStress {
functions {
AllocStress(n: u32) -> AllocStressResult;
}
types {
struct AllocStressResult {
Expand All @@ -12,8 +11,11 @@ program AllocStress {
}
}

service AllocStress {
functions {
AllocStress(n: u32) -> AllocStressResult;
program AllocStress {
constructors {
NewForBench();
}
}
services {
AllocStress,
}
}
12 changes: 6 additions & 6 deletions benchmarks/idls/compute_stress_program.idl
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ program ComputeStress {
services {
ComputeStress,
}
types {
struct ComputeStressResult {
res: u32,
}
}
}

service ComputeStress {
functions {
ComputeStress(n: u32) -> ComputeStressResult;
}
}
types {
struct ComputeStressResult {
res: u32,
}
}
}
4 changes: 2 additions & 2 deletions benchmarks/ping-pong/app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ impl PingPongService {
PingPongPayload::Start(actor_id) => {
let mut api = client::PingPongProgram::client(actor_id).ping_pong_service();
let result = api
.ping(client::PingPongPayload::Ping)
.ping(client::ping_pong_service::PingPongPayload::Ping)
.await
.unwrap_or_else(|e| {
panic!("Failed to receiving successful ping result: {e:?}")
});

if matches!(result, client::PingPongPayload::Pong) {
if matches!(result, client::ping_pong_service::PingPongPayload::Pong) {
PingPongPayload::Finished
} else {
panic!("Unexpected payload received: {result:?}")
Expand Down
20 changes: 10 additions & 10 deletions benchmarks/ping-pong/app/src/ping_pong_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ pub mod io {
use super::*;
sails_rs::io_struct_impl!(NewForBench () -> ());
}
#[derive(PartialEq, Clone, Debug, Encode, Decode, TypeInfo, ReflectHash)]
#[codec(crate = sails_rs::scale_codec)]
#[scale_info(crate = sails_rs::scale_info)]
#[reflect_hash(crate = sails_rs)]
pub enum PingPongPayload {
Start(ActorId),
Ping,
Pong,
Finished,
}

pub mod ping_pong_service {
use super::*;
#[derive(PartialEq, Clone, Debug, Encode, Decode, TypeInfo, ReflectHash)]
#[codec(crate = sails_rs::scale_codec)]
#[scale_info(crate = sails_rs::scale_info)]
#[reflect_hash(crate = sails_rs)]
pub enum PingPongPayload {
Start(ActorId),
Ping,
Pong,
Finished,
}
pub trait PingPongService {
type Env: sails_rs::client::GearEnv;
fn ping(
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/ping-pong/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ repository.workspace = true
[build-dependencies]
ping-pong-bench-app = { path = "../app" }
sails-client-gen.workspace = true
# TODO: Switch to new IDL generator crate
# sails-idl-gen.workspace = true
sails-idl-gen.workspace = true
8 changes: 4 additions & 4 deletions benchmarks/ping-pong/client/build.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// use ping_pong_bench_app::PingPongProgram;
use ping_pong_bench_app::PingPongProgram;

fn main() {
let idl_file_path = std::path::PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap())
.join("ping_pong.idl");

// Generate IDL file for the `AllocStress` app
// TODO: uncomment
// sails_idl_gen::generate_idl_to_file::<PingPongProgram>(&idl_file_path).unwrap();
// Generate IDL file for the `PingPongProgram` app
sails_idl_gen::generate_idl_to_file::<PingPongProgram>(Some("PingPong"), &idl_file_path)
.unwrap();

// Generate client code from IDL file
sails_client_gen::ClientGenerator::from_idl_path(&idl_file_path)
Expand Down
23 changes: 13 additions & 10 deletions benchmarks/ping-pong/client/ping_pong.idl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
program PingPongProgram {
constructors {
NewForBench();
}
services {
PingPongService,

!@sails: 0.9.2

service PingPongService {
functions {
Ping(payload: PingPongPayload) -> PingPongPayload;
}
types {
enum PingPongPayload {
Expand All @@ -15,8 +15,11 @@ program PingPongProgram {
}
}

service PingPongService {
functions {
Ping(payload: PingPongPayload) -> PingPongPayload;
program PingPong {
constructors {
NewForBench();
}
}
services {
PingPongService,
}
}
34 changes: 16 additions & 18 deletions benchmarks/src/alloc_stress_program.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
// Code generated by sails-client-gen. DO NOT EDIT.
#[allow(unused_imports)]
use sails_rs::{client::*, collections::*, prelude::*};
pub struct AllocStressProgramProgram;
impl sails_rs::client::Program for AllocStressProgramProgram {}
pub trait AllocStressProgram {
pub struct AllocStressProgram;
impl sails_rs::client::Program for AllocStressProgram {}
pub trait AllocStress {
type Env: sails_rs::client::GearEnv;
fn alloc_stress(&self) -> sails_rs::client::Service<alloc_stress::AllocStressImpl, Self::Env>;
}
impl<E: sails_rs::client::GearEnv> AllocStressProgram
for sails_rs::client::Actor<AllocStressProgramProgram, E>
{
impl<E: sails_rs::client::GearEnv> AllocStress for sails_rs::client::Actor<AllocStressProgram, E> {
type Env = E;
fn alloc_stress(&self) -> sails_rs::client::Service<alloc_stress::AllocStressImpl, Self::Env> {
self.service(stringify!(AllocStress))
}
}
pub trait AllocStressProgramCtors {
pub trait AllocStressCtors {
type Env: sails_rs::client::GearEnv;
fn new_for_bench(
self,
) -> sails_rs::client::PendingCtor<AllocStressProgramProgram, io::NewForBench, Self::Env>;
) -> sails_rs::client::PendingCtor<AllocStressProgram, io::NewForBench, Self::Env>;
}
impl<E: sails_rs::client::GearEnv> AllocStressProgramCtors
for sails_rs::client::Deployment<AllocStressProgramProgram, E>
impl<E: sails_rs::client::GearEnv> AllocStressCtors
for sails_rs::client::Deployment<AllocStressProgram, E>
{
type Env = E;
fn new_for_bench(
self,
) -> sails_rs::client::PendingCtor<AllocStressProgramProgram, io::NewForBench, Self::Env> {
) -> sails_rs::client::PendingCtor<AllocStressProgram, io::NewForBench, Self::Env> {
self.pending_ctor(())
}
}
Expand All @@ -36,16 +34,16 @@ pub mod io {
use super::*;
sails_rs::io_struct_impl!(NewForBench () -> ());
}
#[derive(PartialEq, Clone, Debug, Encode, Decode, TypeInfo, ReflectHash)]
#[codec(crate = sails_rs::scale_codec)]
#[scale_info(crate = sails_rs::scale_info)]
#[reflect_hash(crate = sails_rs)]
pub struct AllocStressResult {
pub inner: Vec<u8>,
}

pub mod alloc_stress {
use super::*;
#[derive(PartialEq, Clone, Debug, Encode, Decode, TypeInfo, ReflectHash)]
#[codec(crate = sails_rs::scale_codec)]
#[scale_info(crate = sails_rs::scale_info)]
#[reflect_hash(crate = sails_rs)]
pub struct AllocStressResult {
pub inner: Vec<u8>,
}
pub trait AllocStress {
type Env: sails_rs::client::GearEnv;
fn alloc_stress(
Expand Down
Loading