Skip to content

Commit

Permalink
use_new_metering cli option
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyan-dfinity committed Oct 7, 2023
1 parent a2c7d12 commit d3ef0f4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ic-repl"
version = "0.5.0"
version = "0.5.1"
authors = ["DFINITY Team"]
edition = "2021"
default-run = "ic-repl"
Expand Down
5 changes: 3 additions & 2 deletions src/exp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ impl Exp {
"wasm_profiling" => match args.as_slice() {
[IDLValue::Text(file)] | [IDLValue::Text(file), IDLValue::Record(_)] => {
use ic_wasm::instrumentation::{instrument, Config};
let use_new_metering = helper.use_new_metering;
let path = resolve_path(&helper.base_path, file);
let blob = std::fs::read(&path)
.with_context(|| format!("Cannot read {path:?}"))?;
Expand Down Expand Up @@ -224,15 +225,15 @@ impl Exp {
trace_only_funcs,
start_address: start_page.map(|page| page * 65536),
page_limit,
use_new_metering: false,
use_new_metering,
}
}
Some(_) => unreachable!(),
None => Config {
trace_only_funcs: vec![],
start_address: None,
page_limit: None,
use_new_metering: false,
use_new_metering,
},
};
instrument(&mut m, config).map_err(|e| anyhow::anyhow!("{e}"))?;
Expand Down
3 changes: 3 additions & 0 deletions src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub struct MyHelper {
pub base_path: std::path::PathBuf,
pub history: Vec<String>,
pub messages: RefCell<Vec<crate::offline::IngressWithStatus>>,
pub use_new_metering: bool,
}

impl MyHelper {
Expand All @@ -116,6 +117,7 @@ impl MyHelper {
agent_url: self.agent_url.clone(),
offline: self.offline.clone(),
messages: self.messages.clone(),
use_new_metering: self.use_new_metering,
}
}
pub fn new(agent: Agent, agent_url: String, offline: Option<OfflineOutput>) -> Self {
Expand All @@ -137,6 +139,7 @@ impl MyHelper {
agent,
agent_url,
offline,
use_new_metering: false,
};
res.fetch_root_key_if_needed().unwrap();
res.load_prelude().unwrap();
Expand Down
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ fn repl(opts: Opts) -> anyhow::Result<()> {
.history_ignore_space(true)
.completion_type(CompletionType::List)
.build();
let h = MyHelper::new(agent, url.to_string(), offline);
let mut h = MyHelper::new(agent, url.to_string(), offline);
h.use_new_metering = opts.use_new_metering;
if let Some(file) = opts.send {
use crate::offline::{send_messages, Messages};
let json = std::fs::read_to_string(file)?;
Expand Down Expand Up @@ -149,6 +150,9 @@ struct Opts {
#[clap(short, long, conflicts_with("script"), conflicts_with("offline"))]
/// Send signed messages
send: Option<String>,
#[clap(short, long)]
/// Use new metering with wasm_profiling. This option will be removed once the mainnet is using the new metering.
use_new_metering: bool,
}

fn main() -> anyhow::Result<()> {
Expand Down

0 comments on commit d3ef0f4

Please sign in to comment.