-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: prepare and dump state inside params-estimator
#4706
Changes from 23 commits
350209f
b1cbdd9
8cfc449
2f898f2
fccd259
e17c864
8809c03
fbd16f2
35969ad
a7b18c1
f4cff16
40233c0
6fc105a
1b8b2ce
b531f84
7879ee9
f24da54
c6bed4a
17c2223
e3f2811
def0387
3e3a7ac
9bf5a64
92b24d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ near-vm-runner = {path = "../../runtime/near-vm-runner" } | |
node-runtime = { path = "../../runtime/runtime" } | ||
near-store = { path = "../../core/store" } | ||
near-primitives = { path = "../../core/primitives" } | ||
near-test-contracts = { path = "../../runtime/near-test-contracts" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I am surprised that estimator uses both |
||
|
||
testlib = { path = "../../test-utils/testlib" } | ||
state-viewer = { path = "../../test-utils/state-viewer" } | ||
nearcore = { path = "../../nearcore" } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,15 +32,14 @@ Start container and build estimator with: | |
host> ./run.sh | ||
docker> cd /host/nearcore | ||
docker> cargo run -j2 --release --package neard --bin neard -- --home /tmp/data init --test-seed=alice.near --account-id=test.near --fast | ||
docker> cargo run -j2 --release --package genesis-populate --bin genesis-populate -- --additional-accounts-num=200000 --home /tmp/data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for remebering to update the docs! |
||
docker> cd /host/nearcore/runtime/runtime-params-estimator | ||
docker> pushd ./test-contract && ./build.sh && popd | ||
docker> cargo build --release --package runtime-params-estimator --features required | ||
|
||
Now start the estimator under QEMU with the counter plugin enabled (note, that Rust compiler produces SSE4, so specify recent CPU): | ||
|
||
docker> ./emu-cost/counter_plugin/qemu-x86_64 -cpu Westmere-v1 -plugin file=./emu-cost/counter_plugin/libcounter.so \ | ||
../../target/release/runtime-params-estimator --home /tmp/data --accounts-num 20000 --iters 1 --warmup-iters 1 | ||
../../target/release/runtime-params-estimator --home /tmp/data --accounts-num 20000 --additional-accounts-num 200000 --iters 1 --warmup-iters 1 | ||
|
||
### Notes | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
use anyhow::Context; | ||
use clap::Clap; | ||
use genesis_populate::GenesisBuilder; | ||
use near_store::create_store; | ||
use near_vm_runner::VMKind; | ||
use nearcore::get_default_home; | ||
use nearcore::{get_default_home, get_store_path, load_config}; | ||
use runtime_params_estimator::cases::run; | ||
use runtime_params_estimator::costs_to_runtime_config; | ||
use runtime_params_estimator::testbed_runners::Config; | ||
|
@@ -13,6 +15,7 @@ use std::fs; | |
use std::path::Path; | ||
use std::path::PathBuf; | ||
use std::process::Command; | ||
use std::sync::Arc; | ||
use std::time; | ||
|
||
#[derive(Clap)] | ||
|
@@ -26,9 +29,12 @@ struct CliArgs { | |
/// How many iterations per block are we going to try. | ||
#[clap(long, default_value = "10")] | ||
iters: usize, | ||
/// How many accounts were generated with `genesis-populate`. | ||
#[clap(long, default_value = "10000")] | ||
/// Number of active accounts in the state (accounts used for estimation). | ||
#[clap(long, default_value = "20000")] | ||
accounts_num: usize, | ||
/// Number of additional accounts to add to the state, among which active accounts are selected. | ||
#[clap(long, default_value = "200000")] | ||
additional_accounts_num: usize, | ||
/// What metric to use. | ||
#[clap(long, default_value = "icount", possible_values = &["icount", "time"])] | ||
metric: String, | ||
|
@@ -53,6 +59,24 @@ fn main() -> anyhow::Result<()> { | |
|
||
let state_dump_path = cli_args.home.unwrap_or_else(|| get_default_home().into()); | ||
|
||
let additional_accounts_num = cli_args.additional_accounts_num as u64; | ||
if additional_accounts_num > 0 { | ||
let near_config = load_config(&state_dump_path); | ||
let store = create_store(&get_store_path(&state_dump_path)); | ||
GenesisBuilder::from_config_and_store( | ||
&state_dump_path, | ||
Arc::new(near_config.genesis), | ||
store, | ||
) | ||
.add_additional_accounts(additional_accounts_num) | ||
.add_additional_accounts_contract(near_test_contracts::tiny_contract().to_vec()) | ||
.print_progress() | ||
.build() | ||
.unwrap() | ||
.dump_state() | ||
.unwrap(); | ||
} | ||
|
||
if cli_args.docker { | ||
return main_docker(&state_dump_path); | ||
} | ||
|
@@ -146,6 +170,7 @@ fn main_docker(state_dump_path: &Path) -> anyhow::Result<()> { | |
|
||
let mut buf = String::new(); | ||
buf.push_str("set -ex;\n"); | ||
buf.push_str("cd /host/nearcore;\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
buf.push_str( | ||
"\ | ||
cargo build --manifest-path /host/nearcore/Cargo.toml \ | ||
|
@@ -167,6 +192,11 @@ cargo build --manifest-path /host/nearcore/Cargo.toml \ | |
while let Some(arg) = args.next() { | ||
match arg.as_str() { | ||
"--docker" => continue, | ||
"--additional-accounts-num" => { | ||
args.next(); | ||
write!(buf, " {:?} 0", arg).unwrap(); | ||
continue; | ||
} | ||
"--home" => { | ||
args.next(); | ||
continue; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉