Skip to content

Commit

Permalink
Add the skeleton for the flamegraph target binary
Browse files Browse the repository at this point in the history
  • Loading branch information
popzxc committed Feb 2, 2022
1 parent 63964bf commit bc50e35
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ members = [
"core/lib/balancer",

# Test infrastructure
"core/tests/flamegraph_target",
"core/tests/test_account",
"core/tests/testkit",
"core/tests/loadnext",
Expand Down
15 changes: 15 additions & 0 deletions core/tests/flamegraph_target/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "flamegraph_target"
version = "0.1.0"
edition = "2018"
authors = ["The Matter Labs Team <[email protected]>"]
homepage = "https://zksync.io/"
repository = "https://github.com/matter-labs/zksync"
license = "Apache-2.0"
keywords = ["blockchain", "zksync"]
categories = ["cryptography"]
publish = false # We don't want to publish our tests.

[dependencies]
zksync_crypto = { path = "../../lib/crypto", version = "1.0" }
structopt = "0.3.20"
22 changes: 22 additions & 0 deletions core/tests/flamegraph_target/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# zkSync flamegraph target

This binary is a playground for analyzing the performance of the zkSync components, using tools
such as [perf] and [cargo-flamegraph].

While analyzing the performance of the application overall may be useful, it doesn't really help
when you want to analyze one particular component when it takes ~100% of the runtime, in order to
see weak points clearly.

[perf]: https://perf.wiki.kernel.org/index.php/Main_Page
[cargo-flamegraph]: https://github.com/flamegraph-rs/flamegraph

## Design notes

Since the goal is to avoid *everything* that is not related to the analysis of the particular component,
try to avoid "hidden" runtime logic such as async runtimes (e.g. `tokio::main`) or logging (e.g. `vlog`)
in this crate. If the code you are going to analyze requires `async` support, explicitly create the runtime
for said code only.

Target code should be written in a manner that stresses component in the most possible way.
If your code needs initialization, separate it from the actual stressing logic, so that in the resulting
flamegraph they will be easily distinguishable.
1 change: 1 addition & 0 deletions core/tests/flamegraph_target/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}

0 comments on commit bc50e35

Please sign in to comment.