Skip to content

Commit

Permalink
report compute units without tx_wide_compute_cap feature enabled (sol…
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones authored Dec 2, 2021
1 parent f0b32b7 commit bf5b7f5
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions runtime/src/message_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ impl MessageProcessor {
blockhash,
lamports_per_signature,
);
let compute_meter = invoke_context.get_compute_meter();

debug_assert_eq!(program_indices.len(), message.instructions.len());
for (instruction_index, (instruction, program_indices)) in message
Expand All @@ -87,9 +86,6 @@ impl MessageProcessor {
continue;
}

let mut time = Measure::start("execute_instruction");
let pre_remaining_units = compute_meter.borrow().get_remaining();

// Fixup the special instructions key if present
// before the account pre-values are taken care of
for (pubkey, accont) in accounts.iter().take(message.account_keys.len()) {
Expand All @@ -107,22 +103,27 @@ impl MessageProcessor {
let result = invoke_context
.push(message, instruction, program_indices, None)
.and_then(|_| {
let pre_remaining_units =
invoke_context.get_compute_meter().borrow().get_remaining();
let mut time = Measure::start("execute_instruction");

invoke_context.process_instruction(&instruction.data)?;
invoke_context.verify(message, instruction, program_indices)?;

time.stop();
let post_remaining_units =
invoke_context.get_compute_meter().borrow().get_remaining();
timings.accumulate_program(
instruction.program_id(&message.account_keys),
time.as_us(),
pre_remaining_units - post_remaining_units,
);
timings.accumulate(&invoke_context.timings);
Ok(())
})
.map_err(|err| TransactionError::InstructionError(instruction_index as u8, err));
invoke_context.pop();

time.stop();
let post_remaining_units = compute_meter.borrow().get_remaining();
timings.accumulate_program(
instruction.program_id(&message.account_keys),
time.as_us(),
pre_remaining_units - post_remaining_units,
);

result?;
}
Ok(())
Expand Down

0 comments on commit bf5b7f5

Please sign in to comment.