Skip to content

Commit 5c22a14

Browse files
feat: disable profiling during deployments (#314)
1 parent 6211c36 commit 5c22a14

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

crates/cli/src/cli/simnet/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use serde::{Deserialize, Serialize};
2020
use solana_keypair::Keypair;
2121
use solana_signer::Signer;
2222
use surfpool_core::{start_local_surfnet, surfnet::svm::SurfnetSvm};
23-
use surfpool_types::{SanitizedConfig, SimnetEvent, SubgraphEvent};
23+
use surfpool_types::{SanitizedConfig, SimnetCommand, SimnetEvent, SubgraphEvent};
2424
use txtx_core::kit::{
2525
channel::Receiver, futures::future::join_all, helpers::fs::FileLocation,
2626
types::frontend::BlockEvent,
@@ -199,6 +199,7 @@ pub async fn handle_start_local_surfnet_command(
199199
subgraph_events_rx,
200200
cmd.debug,
201201
deploy_progress_rx,
202+
simnet_commands_tx,
202203
)?;
203204
} else {
204205
tui::simnet::start_app(
@@ -222,6 +223,7 @@ fn log_events(
222223
subgraph_events_rx: Receiver<SubgraphEvent>,
223224
include_debug_logs: bool,
224225
deploy_progress_rx: Vec<Receiver<BlockEvent>>,
226+
simnet_commands_tx: Sender<SimnetCommand>,
225227
) -> Result<(), String> {
226228
let mut deployment_completed = false;
227229
let stop_loop = Arc::new(AtomicBool::new(false));
@@ -324,10 +326,14 @@ fn log_events(
324326
SimnetEvent::RunbookStarted(runbook_id) => {
325327
deployment_completed = false;
326328
info!("Runbook '{}' execution started", runbook_id);
329+
let _ =
330+
simnet_commands_tx.send(SimnetCommand::SetInstructionProfiling(false));
327331
}
328332
SimnetEvent::RunbookCompleted(runbook_id) => {
329333
deployment_completed = true;
330334
info!("Runbook '{}' execution completed", runbook_id);
335+
let _ =
336+
simnet_commands_tx.send(SimnetCommand::SetInstructionProfiling(true));
331337
}
332338
},
333339
Err(_e) => {
@@ -372,6 +378,7 @@ fn log_events(
372378
},
373379
Err(_e) => {
374380
deployment_completed = true;
381+
let _ = simnet_commands_tx.send(SimnetCommand::SetInstructionProfiling(true));
375382
}
376383
},
377384
}
@@ -389,7 +396,6 @@ async fn write_and_execute_iac(
389396
.map_err(|e| format!("Failed to detect project framework: {}", e))?;
390397

391398
let (progress_tx, progress_rx) = crossbeam::channel::unbounded();
392-
393399
if let Some((framework, programs)) = deployment {
394400
// Is infrastructure-as-code (IaC) already setup?
395401
let base_location =

crates/cli/src/tui/simnet.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,9 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<(
548548
Local::now(),
549549
format!("Runbook '{}' execution started", runbook_id),
550550
));
551+
let _ = app
552+
.simnet_commands_tx
553+
.send(SimnetCommand::SetInstructionProfiling(false));
551554
}
552555
SimnetEvent::RunbookCompleted(runbook_id) => {
553556
deployment_completed = true;
@@ -556,6 +559,9 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<(
556559
Local::now(),
557560
format!("Runbook '{}' execution completed", runbook_id),
558561
));
562+
let _ = app
563+
.simnet_commands_tx
564+
.send(SimnetCommand::SetInstructionProfiling(true));
559565
app.status_bar_message = None;
560566
}
561567
},
@@ -651,6 +657,9 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<(
651657
},
652658
Err(_) => {
653659
deployment_completed = true;
660+
let _ = app
661+
.simnet_commands_tx
662+
.send(SimnetCommand::SetInstructionProfiling(true));
654663
break;
655664
}
656665
},

crates/core/src/runloops/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ pub async fn start_block_production_runloop(
221221
let _ = svm_locker.simnet_events_tx().send(SimnetEvent::Aborted("Terminated due to inactivity.".to_string()));
222222
break;
223223
}
224+
SimnetCommand::SetInstructionProfiling(enabled) => {
225+
svm_locker.with_svm_writer(|svm_writer| {
226+
svm_writer.instruction_profiling_enabled = enabled;
227+
});
228+
}
224229
}
225230
},
226231
}

crates/types/src/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ pub enum SimnetCommand {
463463
bool,
464464
),
465465
Terminate(Option<(Hash, String)>),
466+
SetInstructionProfiling(bool),
466467
}
467468

468469
#[derive(Debug)]

0 commit comments

Comments
 (0)