Skip to content

Commit c7ba5f7

Browse files
Add jiminy results using solana v2.2.6 and also binary sizes comparison (#2)
* upgrade to solana 2.2.6 * jiminy-init-sux * add jiminy bench results * add results and binary size section * update jiminy to master * copy * upgrade, update * cleanup deps * no change * update * update * update, no change to results * fix rust fmt
1 parent 7650b29 commit c7ba5f7

10 files changed

Lines changed: 342 additions & 13 deletions

File tree

Cargo.lock

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
resolver = "2"
33
members = [
44
"benchmark",
5+
"programs/jiminy",
56
"programs/pinocchio",
67
"programs/solana-nostd-entrypoint",
78
"programs/solana-program"

README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,37 @@ Entrypoint implementation currently included in the benchmark:
1919
- [`pinocchio`](https://github.com/anza-xyz/pinocchio)
2020
- [`solana-nostd-entrypoint`](https://github.com/cavemanloverboy/solana-nostd-entrypoint)
2121
- [`solana-program`](https://github.com/anza-xyz/agave/tree/master/sdk/program)
22+
- [`jiminy`](https://github.com/igneous-labs/jiminy)
2223

23-
| Benchmark | `pinocchio` | `solana-nostd-entrypoint` | `solana-program` |
24-
| ------------- | ------------ | ------------------------- | ----------------- |
24+
| Benchmark | `pinocchio` | `solana-nostd-entrypoint` | `solana-program` | `jiminy` |
25+
| ------------- | --------------- | ------------------------- | ----------------- | ------------ |
2526
| _Entrypoint_ |
26-
| Ping | 🟩 **14** | 🟩 **14** | 🟧 41 (+27) |
27-
| Log | 🟩 **119** | 🟩 **119** | 🟧 146 (+27) |
28-
| Account (1) | 🟩 **38** | 🟩 39 (+1) | 🟥 235 (+196) |
29-
| Account (3) | 🟩 **66** | 🟩 69 (+3) | 🟥 541 (+475) |
30-
| Account (5) | 🟩 **94** | 🟩 99 (+5) | 🟥 847 (+753) |
31-
| Account (10) | 🟩 **164** | 🟩 174 (+10) | 🟥 1,612 (+1,448) |
32-
| Account (20) | 🟩 **304** | 🟨 324 (+20) | 🟥 3,142 (+2,838) |
33-
| Account (32) | 🟩 **472** | 🟨 504 (+32) | 🟥 4,978 (+4,506) |
34-
| Account (64) | 🟩 **920** | 🟨 985 (+65) | 🟥 9,874 (+8,954) |
27+
| Ping | 🟩 **14** | 🟩 **14** | 🟧 41 (+27) | 🟩 **14** |
28+
| Log | 🟩 **119** | 🟩 **119** | 🟧 146 (+27) | 🟩 **119** |
29+
| Account (1) | 🟩 38 (+2) | 🟩 39 (+3) | 🟥 235 (+199) | 🟩 **36** |
30+
| Account (3) | 🟩 **66** | 🟩 69 (+3) | 🟥 541 (+475) | 🟩 **66** |
31+
| Account (5) | 🟩 **94** | 🟩 99 (+5) | 🟥 847 (+751) | 🟩 96 (+2) |
32+
| Account (10) | 🟩 **164** | 🟩 174 (+10) | 🟥 1,612 (+1,441) | 🟩 171 (+7) |
33+
| Account (20) | 🟩 **304** | 🟨 324 (+20) | 🟥 3,142 (+2,821) | 🟨 321 (+17) |
34+
| Account (32) | 🟩 **472** | 🟨 504 (+32) | 🟥 4,978 (+4,477) | 🟨 501 (+29) |
35+
| Account (64) | 🟩 **920** | 🟨 985 (+65) | 🟥 9,874 (+8,893) | 🟨 981 (+61) |
3536
| _CPI_ |
36-
| CreateAccount | 🟩 **1,449** | 🟨 1,494 (+45) | 🟥 2,786 (+1,337) |
37-
| Transfer | 🟩 **1,439** | 🟨 1,487 (+48) | 🟥 2,379 (+940) |
37+
| CreateAccount | 🟨 1,449 (+142) | 🟨 1,494 (+187) | 🟥 2,786 (+1,479) | 🟩 **1,307** |
38+
| Transfer | 🟨 1,439 (+140) | 🟨 1,487 (+180) | 🟥 2,379 (+1,080) | 🟩 **1,299** |
3839

3940
> [!IMPORTANT]
4041
> Values correspond to compute units (CUs) consumed by the entrypoint. The delta in relation to the lowest consumption is shown in brackets.
4142
>
4243
> Solana CLI `v2.2.6` was used in the bench tests.
4344
45+
## Binary Sizes
46+
47+
The size of the compiled benchmark program for each entrypoint is shown below. The delta in relation to the smallest binary size is shown in brackets.
48+
49+
| Binary size (bytes) | `pinocchio` | `solana-nostd-entrypoint` | `solana-program` | `jiminy` |
50+
| ------------------- | ------------------ | ------------------------- | ------------------- | -------- |
51+
| | 🟥 10,736 (+7,240) | 🟥 17,720 (+14,224) | 🟥 64,688 (+61,192) | 🟩 3,496 |
52+
4453
## Benchmark
4554

4655
The benchmark uses a simple program with multiple instructions to measure the compute units (CUs) consumed by the entrypoint. Note that the intention is not to write the most efficient program, instead to reflect an "average" program implementation. The aim is to use the exactly same program implementation, replacing the entrypoint to determine the impact on the CUs consumed.

benchmark/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ name = "coyote"
77
path = "src/main.rs"
88

99
[dev-dependencies]
10+
eisodos-jiminy = { path="../programs/jiminy" }
1011
eisodos-pinocchio = { path="../programs/pinocchio" }
1112
eisodos-solana-nostd-entrypoint = { path="../programs/solana-nostd-entrypoint" }
1213
eisodos-solana-program = { path="../programs/solana-program" }

benchmark/benches/jiminy.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![feature(test)]
2+
3+
extern crate mollusk_svm;
4+
extern crate mollusk_svm_bencher;
5+
extern crate solana_account;
6+
extern crate solana_instruction;
7+
extern crate solana_pubkey;
8+
extern crate test;
9+
10+
mod setup;
11+
use setup::*;
12+
13+
#[cfg(test)]
14+
mod jiminy {
15+
16+
use super::*;
17+
use test::Bencher;
18+
19+
#[bench]
20+
fn run(_bencher: &mut Bencher) {
21+
runner::run(&eisodos_jiminy::ID.into(), "eisodos_jiminy");
22+
}
23+
}

programs/jiminy/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "eisodos-jiminy"
3+
version = "0.0.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[package.metadata.solana]
8+
program-id = "Jim1ny1111111111111111111111111111111111111"
9+
10+
[lints.rust.unexpected_cfgs]
11+
level = "warn"
12+
check-cfg = [
13+
'cfg(target_os, values("solana"))',
14+
]
15+
16+
[lib]
17+
crate-type = ["cdylib", "lib"]
18+
19+
[dependencies]
20+
const-crypto = { version = "^0.3", default-features = false }
21+
jiminy-cpi = { git = "https://github.com/igneous-labs/jiminy", branch = "master" }
22+
jiminy-entrypoint = { git = "https://github.com/igneous-labs/jiminy", branch = "master" }
23+
jiminy-log = { git = "https://github.com/igneous-labs/jiminy", branch = "master" }
24+
jiminy-syscall = { git = "https://github.com/igneous-labs/jiminy", branch = "master" }
25+
jiminy-system-prog-interface = { git = "https://github.com/igneous-labs/jiminy", branch = "master" }

programs/jiminy/src/entrypoint.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::{
2+
instruction::Instruction,
3+
processor::{
4+
process_account, process_create_account, process_log, process_ping, process_transfer,
5+
},
6+
Accounts, ProgramResult, MAX_ACCOUNTS,
7+
};
8+
use jiminy_entrypoint::entrypoint;
9+
10+
entrypoint!(process_instruction, MAX_ACCOUNTS);
11+
12+
#[inline(always)]
13+
pub fn process_instruction(
14+
accounts: &mut Accounts,
15+
instruction_data: &[u8],
16+
_program_id: &[u8; 32],
17+
) -> ProgramResult {
18+
let instruction = Instruction::unpack(instruction_data)?;
19+
20+
match instruction {
21+
Instruction::Ping => process_ping(),
22+
Instruction::Log => process_log(),
23+
Instruction::Account { expected } => process_account(accounts, expected),
24+
Instruction::CreateAccount => process_create_account(accounts),
25+
Instruction::Transfer => process_transfer(accounts),
26+
}
27+
}

programs/jiminy/src/instruction.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use jiminy_entrypoint::program_error::{BuiltInProgramError, ProgramError};
2+
3+
#[derive(Clone, Debug)]
4+
#[rustfmt::skip]
5+
pub enum Instruction {
6+
Ping,
7+
Log,
8+
Account {
9+
expected: u64,
10+
},
11+
CreateAccount,
12+
Transfer,
13+
}
14+
15+
impl Instruction {
16+
/// Unpacks a byte buffer into a [Instruction](enum.Instruction.html).
17+
#[inline(always)]
18+
pub fn unpack(input: &[u8]) -> Result<Self, ProgramError> {
19+
match input.split_first() {
20+
// 0 - Ping
21+
Some((&0, [])) => Ok(Instruction::Ping),
22+
// 1 - Log
23+
Some((&1, [])) => Ok(Instruction::Log),
24+
// 2 - Account
25+
Some((&2, remaining)) if remaining.len() == 8 => Ok(Instruction::Account {
26+
expected: u64::from_le_bytes(remaining[0..8].try_into().unwrap()),
27+
}),
28+
// 3 - CreateAccount
29+
Some((&3, [])) => Ok(Instruction::CreateAccount),
30+
// 4 - Transfer
31+
Some((&4, [])) => Ok(Instruction::Transfer),
32+
_ => Err(ProgramError::from_builtin(
33+
BuiltInProgramError::InvalidInstructionData,
34+
)),
35+
}
36+
}
37+
}

programs/jiminy/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use jiminy_entrypoint::program_error::ProgramError;
2+
3+
pub mod entrypoint;
4+
pub mod instruction;
5+
pub mod processor;
6+
7+
type ProgramResult = Result<(), ProgramError>;
8+
9+
const MAX_ACCOUNTS: usize = 128;
10+
// TODO: CPI takes up way too much stack space
11+
const MAX_CPI_ACCOUNTS: usize = 36;
12+
13+
type Cpi = jiminy_cpi::Cpi<MAX_CPI_ACCOUNTS>;
14+
15+
type Accounts<'a> = jiminy_entrypoint::account::Accounts<'a, MAX_ACCOUNTS>;
16+
17+
const PROG_ID_STR: &str = "Jim1ny1111111111111111111111111111111111111";
18+
19+
pub const ID: [u8; 32] = const_crypto::bs58::decode_pubkey(PROG_ID_STR);

0 commit comments

Comments
 (0)