Skip to content
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

fix: Add trailing extra arguments for backend in gates_flamegraph #7472

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion noir-projects/noir-protocol-circuits/scripts/flamegraph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ DEST="$SCRIPT_DIR/../dest"
mkdir -p $DEST

# At last, generate the flamegraph.
$PROFILER gates-flamegraph --artifact-path "${ARTIFACT}" --backend-path "$SCRIPT_DIR/../../../barretenberg/cpp/build/bin/bb" --output "$DEST"
$PROFILER gates-flamegraph --artifact-path "${ARTIFACT}" --backend-path "$SCRIPT_DIR/../../../barretenberg/cpp/build/bin/bb" --output "$DEST" -- -h

# Serve the file over http if -s is set.
if $SERVE; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ pub(crate) struct GatesFlamegraphCommand {
#[clap(long, short)]
backend_path: String,

#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
backend_extra_args: Vec<String>,

/// The output folder for the flamegraph svg files
#[clap(long, short)]
output: String,
Expand All @@ -27,7 +30,10 @@ pub(crate) struct GatesFlamegraphCommand {
pub(crate) fn run(args: GatesFlamegraphCommand) -> eyre::Result<()> {
run_with_provider(
&PathBuf::from(args.artifact_path),
&BackendGatesProvider { backend_path: PathBuf::from(args.backend_path) },
&BackendGatesProvider {
backend_path: PathBuf::from(args.backend_path),
extra_args: args.backend_extra_args,
},
&InfernoFlamegraphGenerator { count_name: "gates".to_string() },
&PathBuf::from(args.output),
)
Expand Down
12 changes: 10 additions & 2 deletions noir/noir-repo/tooling/profiler/src/gates_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ pub(crate) trait GatesProvider {

pub(crate) struct BackendGatesProvider {
pub(crate) backend_path: PathBuf,
pub(crate) extra_args: Vec<String>,
}

impl GatesProvider for BackendGatesProvider {
fn get_gates(&self, artifact_path: &Path) -> eyre::Result<BackendGatesResponse> {
let backend_gates_response =
Command::new(&self.backend_path).arg("gates").arg("-b").arg(artifact_path).output()?;
let mut backend_gates_cmd = Command::new(&self.backend_path);

backend_gates_cmd.arg("gates").arg("-b").arg(artifact_path);

for arg in &self.extra_args {
backend_gates_cmd.arg(arg);
}

let backend_gates_response = backend_gates_cmd.output()?;

// Parse the backend gates command stdout as json
let backend_gates_response: BackendGatesResponse =
Expand Down
Loading