Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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
115 changes: 115 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
resolver = "2"
members = [
"benchmark",
"programs/jiminy",
"programs/pinocchio",
"programs/solana-nostd-entrypoint",
"programs/solana-program"
]

[workspace.metadata.cli]
solana = "2.2.0"
solana = "2.2.6"

[workspace.metadata.toolchains]
format = "1.84.1"
Expand Down
67 changes: 38 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
A simple benchmark of SVM entrypoints.
</p>


## Overview

The purpose of `eisodos` is to offer a simple benchmark of different program entrypoint implementations. An entrypoint is used to parse the [SBF input](https://solana.com/docs/programs/faq#input-parameter-serialization) for a program, providing the information of an instruction input in a "friendly" way. The SBF loader passes the input parameters as a byte array and the entrypoint then transforms the input into separate typed entities &mdash; `program id`, `accounts` array and `instruction data`.
Expand All @@ -17,36 +16,46 @@ The purpose of `eisodos` is to offer a simple benchmark of different program ent

Entrypoint implementation currently included in the benchmark:

* [`pinocchio`](https://github.com/anza-xyz/pinocchio)
* [`solana-nostd-entrypoint`](https://github.com/cavemanloverboy/solana-nostd-entrypoint)
* [`solana-program`](https://github.com/anza-xyz/agave/tree/master/sdk/program)

| Benchmark | `pinocchio` | `solana-nostd-entrypoint` | `solana-program` |
|------------------------|----------------|------------------------------|---------------------|
| *Entrypoint* |
| Ping | 🟩 **14** | 🟩 **15** | 🟧 42 (+28) |
| Log | 🟩 **119** | 🟩 **120** | 🟧 147 (+28) |
| Account (1) | 🟩 **42** | 🟩 **42** | 🟥 242 (+200) |
| Account (3) | 🟩 **70** | 🟩 72 (+2) | 🟥 560 (+490) |
| Account (5) | 🟩 **98** | 🟩 102 (+4) | 🟥 878 (+780) |
| Account (10) | 🟩 **168** | 🟩 177 (+9) | 🟥 1,673 (+1,505) |
| Account (20) | 🟩 **308** | 🟨 327 (+19) | 🟥 3,264 (+2,955) |
| Account (32) | 🟩 **476** | 🟨 507 (+31) | 🟥 5,171 (+4,695) |
| Account (64) | 🟩 **924** | 🟨 988 (+64) | 🟥 10,259 (+9,335) |
| *CPI* |
| CreateAccount | 🟩 **1,443** | 🟨 1,488 (+45) | 🟥 2,867 (+1,424) |
| Transfer | 🟩 **1,433** | 🟨 1,480 (+47) | 🟥 2,415 (+982) |
- [`pinocchio`](https://github.com/anza-xyz/pinocchio)
- [`solana-nostd-entrypoint`](https://github.com/cavemanloverboy/solana-nostd-entrypoint)
- [`solana-program`](https://github.com/anza-xyz/agave/tree/master/sdk/program)
- [`jiminy`](https://github.com/igneous-labs/jiminy)

| Benchmark | `pinocchio` | `solana-nostd-entrypoint` | `solana-program` | `jiminy` |
| ------------- | --------------- | ------------------------- | ----------------- | ------------ |
| _Entrypoint_ |
| Ping | 🟩 **14** | 🟩 **14** | 🟧 41 (+27) | 🟩 **14** |
| Log | 🟩 **119** | 🟩 **119** | 🟧 146 (+27) | 🟩 **119** |
| Account (1) | 🟩 38 (+2) | 🟩 39 (+3) | 🟥 235 (+199) | 🟩 **36** |
| Account (3) | 🟩 **66** | 🟩 69 (+3) | 🟥 541 (+475) | 🟩 **66** |
| Account (5) | 🟩 **94** | 🟩 99 (+5) | 🟥 847 (+751) | 🟩 96 (+2) |
| Account (10) | 🟩 **164** | 🟩 174 (+10) | 🟥 1,612 (+1,441) | 🟩 171 (+7) |
| Account (20) | 🟩 **304** | 🟨 324 (+20) | 🟥 3,142 (+2,821) | 🟨 321 (+17) |
| Account (32) | 🟩 **472** | 🟨 504 (+32) | 🟥 4,978 (+4,477) | 🟨 501 (+29) |
| Account (64) | 🟩 **920** | 🟨 985 (+65) | 🟥 9,874 (+8,893) | 🟨 981 (+61) |
| _CPI_ |
| CreateAccount | 🟨 1,449 (+142) | 🟨 1,494 (+187) | 🟥 2,786 (+1,479) | 🟩 **1,307** |
| Transfer | 🟨 1,439 (+140) | 🟨 1,487 (+180) | 🟥 2,379 (+1,080) | 🟩 **1,299** |

> [!IMPORTANT]
> Values correspond to compute units (CUs) consumed by the entrypoint. The delta in relation to the lowest consumption is shown in brackets.
>
> Solana CLI `v2.2.0` was used in the bench tests.
> Solana CLI `v2.2.6` was used in the bench tests.

## Binary Sizes

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.

| Binary size (bytes) | `pinocchio` | `solana-nostd-entrypoint` | `solana-program` | `jiminy` |
| ------------------- | ------------------ | ------------------------- | ------------------- | -------- |
| | 🟥 10,736 (+7,240) | 🟥 17,720 (+14,224) | 🟥 64,688 (+61,192) | 🟩 3,496 |

## Benchmark

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 implemenation. The aim is to use the exactly same program implementation, replacing the entrypoint to determine the impact on the CUs consumed.
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.

The program used has the following instructions:

```rust
pub enum Instruction {
Ping,
Expand Down Expand Up @@ -83,13 +92,13 @@ This instruction receives 3 accounts (`from`, `to` and `system_program`) and per

The program is structure in 4 different source files:

* `entrypoint.rs`: includes the entrypoint definition and "dispatches" the instruction to the corresponding processor.
- `entrypoint.rs`: includes the entrypoint definition and "dispatches" the instruction to the corresponding processor.

* `instruction.rs`: defines the instructions available on the program and the parsing logic for the input instruction data.
- `instruction.rs`: defines the instructions available on the program and the parsing logic for the input instruction data.

* `lib.rs`: defines the modules of the program and the program ID.
- `lib.rs`: defines the modules of the program and the program ID.

* `processor.rs`: includes the processor for each instruction.
- `processor.rs`: includes the processor for each instruction.

The implementation across all different entrypoint programs is as similar as possible. In most cases, the only differences are on the types import, since each entrypoint defines their own `AccountInfo` and/or `Pubkey` types.

Expand Down Expand Up @@ -119,10 +128,10 @@ The `ENTRYPOINT_NAME` will be one of `pinocchio`, `solana_nostd_entrypoint` or `

The results are written to `./target/benches/compute_units.md`. Each execution is described by 3 columns:

* `Name`: name of the benchmark; this will specify the name of the instruction and the parameters used.
- `Name`: name of the benchmark; this will specify the name of the instruction and the parameters used.

* `CUs`: number of compute units consumed by the execution.
- `CUs`: number of compute units consumed by the execution.

* `Delta`: the difference in compute units between latest benchmark and the previous; this will provide a quick way to assess the differences between entrypoints.
- `Delta`: the difference in compute units between latest benchmark and the previous; this will provide a quick way to assess the differences between entrypoints.

The results of an execution are compared to the previous one (if there is one), with delta differences shown after a `+` and `-` symbol.
1 change: 1 addition & 0 deletions benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name = "coyote"
path = "src/main.rs"

[dev-dependencies]
eisodos-jiminy = { path="../programs/jiminy" }
eisodos-pinocchio = { path="../programs/pinocchio" }
eisodos-solana-nostd-entrypoint = { path="../programs/solana-nostd-entrypoint" }
eisodos-solana-program = { path="../programs/solana-program" }
Expand Down
23 changes: 23 additions & 0 deletions benchmark/benches/jiminy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![feature(test)]

extern crate mollusk_svm;
extern crate mollusk_svm_bencher;
extern crate solana_account;
extern crate solana_instruction;
extern crate solana_pubkey;
extern crate test;

mod setup;
use setup::*;

#[cfg(test)]
mod jiminy {

use super::*;
use test::Bencher;

#[bench]
fn run(_bencher: &mut Bencher) {
runner::run(&eisodos_jiminy::ID.into(), "eisodos_jiminy");
}
}
25 changes: 25 additions & 0 deletions programs/jiminy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "eisodos-jiminy"
version = "0.0.0"
edition = "2021"
publish = false

[package.metadata.solana]
program-id = "Jim1ny1111111111111111111111111111111111111"

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(target_os, values("solana"))',
]

[lib]
crate-type = ["cdylib", "lib"]

[dependencies]
const-crypto = { version = "^0.3", default-features = false }
jiminy-cpi = { git = "https://github.com/igneous-labs/jiminy", branch = "master" }
jiminy-entrypoint = { git = "https://github.com/igneous-labs/jiminy", branch = "master" }
jiminy-log = { git = "https://github.com/igneous-labs/jiminy", branch = "master" }
jiminy-syscall = { git = "https://github.com/igneous-labs/jiminy", branch = "master" }
jiminy-system-prog-interface = { git = "https://github.com/igneous-labs/jiminy", branch = "master" }
27 changes: 27 additions & 0 deletions programs/jiminy/src/entrypoint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use crate::{
instruction::Instruction,
processor::{
process_account, process_create_account, process_log, process_ping, process_transfer,
},
Accounts, ProgramResult, MAX_ACCOUNTS,
};
use jiminy_entrypoint::entrypoint;

entrypoint!(process_instruction, MAX_ACCOUNTS);

#[inline(always)]
pub fn process_instruction(
accounts: &mut Accounts,
instruction_data: &[u8],
_program_id: &[u8; 32],
) -> ProgramResult {
let instruction = Instruction::unpack(instruction_data)?;

match instruction {
Instruction::Ping => process_ping(),
Instruction::Log => process_log(),
Instruction::Account { expected } => process_account(accounts, expected),
Instruction::CreateAccount => process_create_account(accounts),
Instruction::Transfer => process_transfer(accounts),
}
}
Loading