forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor - Move
Executor
in program-runtime crate (solana-labs#28782)
* Moves CreateMetrics into the program-runtime crate. * Moves the Executor trait into executor.rs * Removes the first_instruction_account parameter from Executor::execute().
- Loading branch information
Showing
5 changed files
with
55 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use { | ||
crate::{invoke_context::InvokeContext, timings::ExecuteDetailsTimings}, | ||
solana_sdk::{instruction::InstructionError, saturating_add_assign}, | ||
}; | ||
|
||
/// Program executor | ||
pub trait Executor: std::fmt::Debug + Send + Sync { | ||
/// Execute the program | ||
fn execute(&self, invoke_context: &mut InvokeContext) -> Result<(), InstructionError>; | ||
} | ||
|
||
#[derive(Debug, Default)] | ||
pub struct CreateMetrics { | ||
pub program_id: String, | ||
pub register_syscalls_us: u64, | ||
pub load_elf_us: u64, | ||
pub verify_code_us: u64, | ||
pub jit_compile_us: u64, | ||
} | ||
|
||
impl CreateMetrics { | ||
pub fn submit_datapoint(&self, timings: &mut ExecuteDetailsTimings) { | ||
saturating_add_assign!( | ||
timings.create_executor_register_syscalls_us, | ||
self.register_syscalls_us | ||
); | ||
saturating_add_assign!(timings.create_executor_load_elf_us, self.load_elf_us); | ||
saturating_add_assign!(timings.create_executor_verify_code_us, self.verify_code_us); | ||
saturating_add_assign!(timings.create_executor_jit_compile_us, self.jit_compile_us); | ||
datapoint_trace!( | ||
"create_executor_trace", | ||
("program_id", self.program_id, String), | ||
("register_syscalls_us", self.register_syscalls_us, i64), | ||
("load_elf_us", self.load_elf_us, i64), | ||
("verify_code_us", self.verify_code_us, i64), | ||
("jit_compile_us", self.jit_compile_us, i64), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters