-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2138 from demergent-labs/benchmarking
adding first MVP of benchmarks, they will run on tests now, but will …
- Loading branch information
Showing
184 changed files
with
4,363 additions
and
8,186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"backend": { | ||
"previous": { | ||
"version": "0.25.0", | ||
"benchmarks": [ | ||
{ | ||
"instructions": { "__bigint__": "8136265274" }, | ||
"method_name": "init", | ||
"timestamp": { "__bigint__": "1729788180680976591" } | ||
}, | ||
{ | ||
"instructions": { "__bigint__": "53798727" }, | ||
"method_name": "http_request_update", | ||
"timestamp": { "__bigint__": "1729788197889022797" } | ||
}, | ||
{ | ||
"instructions": { "__bigint__": "47468265" }, | ||
"method_name": "http_request_update", | ||
"timestamp": { "__bigint__": "1729788199085176603" } | ||
}, | ||
{ | ||
"instructions": { "__bigint__": "47474297" }, | ||
"method_name": "http_request_update", | ||
"timestamp": { "__bigint__": "1729788199623240856" } | ||
} | ||
] | ||
}, | ||
"current": { | ||
"version": "0.25.0", | ||
"benchmarks": [ | ||
{ | ||
"instructions": { "__bigint__": "8135491182" }, | ||
"method_name": "init", | ||
"timestamp": { "__bigint__": "1729803431300165877" } | ||
}, | ||
{ | ||
"instructions": { "__bigint__": "53810066" }, | ||
"method_name": "http_request_update", | ||
"timestamp": { "__bigint__": "1729803449326310198" } | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Benchmarks for backend | ||
|
||
## Current benchmarks Azle version: 0.25.0 | ||
|
||
| Id | Method Name | Instructions | Cycles | USD | USD/Million Calls | Change | | ||
| --- | ------------------- | ------------- | ------------- | ------------- | ----------------- | ----------------------------------- | | ||
| 0 | init | 8_135_491_182 | 6_454_786_472 | $0.0085827359 | $8_582.73 | <font color="green">-774_092</font> | | ||
| 1 | http_request_update | 53_810_066 | 22_114_026 | $0.0000294044 | $29.40 | <font color="red">+11_339</font> | | ||
|
||
## Baseline benchmarks Azle version: 0.25.0 | ||
|
||
| Id | Method Name | Instructions | Cycles | USD | USD/Million Calls | | ||
| --- | ------------------- | ------------- | ------------- | ------------- | ----------------- | | ||
| 0 | init | 8_136_265_274 | 6_455_096_109 | $0.0085831476 | $8_583.14 | | ||
| 1 | http_request_update | 53_798_727 | 22_109_490 | $0.0000293983 | $29.39 | | ||
| 2 | http_request_update | 47_468_265 | 19_577_306 | $0.0000260314 | $26.03 | | ||
| 3 | http_request_update | 47_474_297 | 19_579_718 | $0.0000260346 | $26.03 | | ||
|
||
--- | ||
|
||
**Note on calculations:** | ||
|
||
- Cycles are calculated using the formula: base_fee + (per_instruction_fee \* number_of_instructions) + (additional_fee_per_billion \* floor(number_of_instructions / 1_000_000_000)) | ||
- base_fee: 590_000 cycles | ||
- per_instruction_fee: 0.4 cycles | ||
- additional_fee_per_billion: 400_000_000 cycles per billion instructions | ||
- USD value is derived from the total cycles, where 1 trillion cycles = 1 XDR, and 1 XDR = $1.329670 (as of October 24, 2024) | ||
|
||
For the most up-to-date XDR to USD conversion rate, please refer to the [IMF website](https://www.imf.org/external/np/fin/data/rms_sdrv.aspx). | ||
For the most current fee information, please check the [official documentation](https://internetcomputer.org/docs/current/developer-docs/gas-cost#execution). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use std::cell::RefCell; | ||
use std::collections::BTreeMap; | ||
|
||
use candid::CandidType; | ||
use wasmedge_quickjs::{AsObject, Context}; | ||
|
||
#[derive(CandidType, Debug, Clone)] | ||
pub struct BenchmarkEntry { | ||
pub method_name: String, | ||
pub instructions: u64, | ||
pub timestamp: u64, | ||
} | ||
|
||
thread_local! { | ||
pub static BENCHMARKS_REF_CELL: RefCell<Vec<BenchmarkEntry>> = RefCell::new(Vec::new()); | ||
} | ||
|
||
pub fn record_benchmark(context: &mut Context, function_name: &str, instructions: u64) { | ||
let timestamp = ic_cdk::api::time(); | ||
|
||
let global = context.get_global(); | ||
let method_names = global.get("_azleCanisterMethodNames"); | ||
let method_name = method_names | ||
.get(function_name) | ||
.and_then(|v| Some(v.to_string()?.to_string())) | ||
.unwrap_or_else(|| function_name.to_string()); | ||
|
||
BENCHMARKS_REF_CELL.with(|benchmarks_ref_cell| { | ||
let mut benchmarks = benchmarks_ref_cell.borrow_mut(); | ||
benchmarks.push(BenchmarkEntry { | ||
method_name, | ||
instructions, | ||
timestamp, | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.