Skip to content

Commit

Permalink
Revert "add back feature gating to profiler as struct attribute"
Browse files Browse the repository at this point in the history
This reverts commit f25749d.
  • Loading branch information
lanvidr committed Jan 24, 2024
1 parent a9d03e8 commit a11250d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 48 deletions.
7 changes: 1 addition & 6 deletions crates/sui-types/src/gas_model/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use move_core_types::gas_algebra::{AbstractMemorySize, InternalGas, NumArgs, Num
use move_core_types::language_storage::ModuleId;

use move_core_types::vm_status::StatusCode;
#[cfg(feature = "gas-profiler")]
use move_vm_profiler::GasProfiler;
use move_vm_types::gas::{GasMeter, SimpleInstruction};
use move_vm_types::loaded_data::runtime_types::Type;
Expand Down Expand Up @@ -75,7 +74,7 @@ pub struct GasStatus {
instructions_executed: u64,
instructions_next_tier_start: Option<u64>,
instructions_current_tier_mult: u64,
#[cfg(feature = "gas-profiler")]

profiler: Option<GasProfiler>,
}

Expand Down Expand Up @@ -113,7 +112,6 @@ impl GasStatus {
stack_height_next_tier_start,
stack_size_next_tier_start,
instructions_next_tier_start,
#[cfg(feature = "gas-profiler")]
profiler: None,
}
}
Expand Down Expand Up @@ -141,7 +139,6 @@ impl GasStatus {
stack_height_next_tier_start: None,
stack_size_next_tier_start: None,
instructions_next_tier_start: None,
#[cfg(feature = "gas-profiler")]
profiler: None,
}
}
Expand Down Expand Up @@ -673,12 +670,10 @@ impl GasMeter for GasStatus {
self.gas_left
}

#[cfg(feature = "gas-profiler")]
fn get_profiler_mut(&mut self) -> Option<&mut GasProfiler> {
self.profiler.as_mut()
}

#[cfg(feature = "gas-profiler")]
fn set_profiler(&mut self, profiler: GasProfiler) {
self.profiler = Some(profiler);
}
Expand Down
8 changes: 3 additions & 5 deletions external-crates/move/crates/move-vm-profiler/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
#[cfg(feature = "gas-profiler")]
use move_vm_config::runtime::VMProfilerConfig;
use serde::Serialize;
#[cfg(feature = "gas-profiler")]
use std::collections::BTreeMap;

#[cfg(feature = "gas-profiler")]
use tracing::info;

#[cfg(feature = "gas-profiler")]
#[derive(Debug, Clone, Serialize)]
pub struct FrameName {
name: String,
file: String,
}

#[cfg(feature = "gas-profiler")]
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize)]
pub struct Shared {
frames: Vec<FrameName>,
Expand Down Expand Up @@ -44,7 +42,7 @@ pub struct Profile {
events: Vec<Event>,
}

#[cfg(feature = "gas-profiler")]
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GasProfiler {
Expand Down
31 changes: 5 additions & 26 deletions external-crates/move/crates/move-vm-test-utils/src/gas_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use move_core_types::{
u256,
vm_status::StatusCode,
};
#[cfg(feature = "gas-profiler")]
use move_vm_profiler::GasProfiler;
use move_vm_types::{
gas::{GasMeter, SimpleInstruction},
Expand Down Expand Up @@ -114,7 +113,6 @@ pub struct GasStatus<'a> {
cost_table: &'a CostTable,
gas_left: InternalGas,
charge: bool,
#[cfg(feature = "gas-profiler")]
profiler: Option<GasProfiler>,
}

Expand All @@ -128,7 +126,6 @@ impl<'a> GasStatus<'a> {
gas_left: gas_left.to_unit(),
cost_table,
charge: true,
#[cfg(feature = "gas-profiler")]
profiler: None,
}
}
Expand All @@ -142,7 +139,6 @@ impl<'a> GasStatus<'a> {
gas_left: InternalGas::new(0),
cost_table: &ZERO_COST_SCHEDULE,
charge: false,
#[cfg(feature = "gas-profiler")]
profiler: None,
}
}
Expand Down Expand Up @@ -473,12 +469,10 @@ impl<'b> GasMeter for GasStatus<'b> {
self.gas_left
}

#[cfg(feature = "gas-profiler")]
fn get_profiler_mut(&mut self) -> Option<&mut GasProfiler> {
self.profiler.as_mut()
}

#[cfg(feature = "gas-profiler")]
fn set_profiler(&mut self, profiler: GasProfiler) {
self.profiler = Some(profiler);
}
Expand Down Expand Up @@ -511,18 +505,12 @@ pub fn zero_cost_instruction_table() -> Vec<(Bytecode, GasCost)> {
use Bytecode::*;

vec![
(
MoveToDeprecated(StructDefinitionIndex::new(0)),
GasCost::new(0, 0),
),
(MoveToDeprecated(StructDefinitionIndex::new(0)), GasCost::new(0, 0)),
(
MoveToGenericDeprecated(StructDefInstantiationIndex::new(0)),
GasCost::new(0, 0),
),
(
MoveFromDeprecated(StructDefinitionIndex::new(0)),
GasCost::new(0, 0),
),
(MoveFromDeprecated(StructDefinitionIndex::new(0)), GasCost::new(0, 0)),
(
MoveFromGenericDeprecated(StructDefInstantiationIndex::new(0)),
GasCost::new(0, 0),
Expand Down Expand Up @@ -584,10 +572,7 @@ pub fn zero_cost_instruction_table() -> Vec<(Bytecode, GasCost)> {
(LdTrue, GasCost::new(0, 0)),
(Mod, GasCost::new(0, 0)),
(BrFalse(0), GasCost::new(0, 0)),
(
ExistsDeprecated(StructDefinitionIndex::new(0)),
GasCost::new(0, 0),
),
(ExistsDeprecated(StructDefinitionIndex::new(0)), GasCost::new(0, 0)),
(
ExistsGenericDeprecated(StructDefInstantiationIndex::new(0)),
GasCost::new(0, 0),
Expand Down Expand Up @@ -659,10 +644,7 @@ pub fn unit_cost_schedule() -> CostTable {
pub fn bytecode_instruction_costs() -> Vec<(Bytecode, GasCost)> {
use Bytecode::*;
vec![
(
MoveToDeprecated(StructDefinitionIndex::new(0)),
GasCost::new(13, 1),
),
(MoveToDeprecated(StructDefinitionIndex::new(0)), GasCost::new(13, 1)),
(
MoveToGenericDeprecated(StructDefInstantiationIndex::new(0)),
GasCost::new(27, 1),
Expand Down Expand Up @@ -732,10 +714,7 @@ pub fn bytecode_instruction_costs() -> Vec<(Bytecode, GasCost)> {
(LdTrue, GasCost::new(1, 1)),
(Mod, GasCost::new(1, 1)),
(BrFalse(0), GasCost::new(1, 1)),
(
ExistsDeprecated(StructDefinitionIndex::new(0)),
GasCost::new(41, 1),
),
(ExistsDeprecated(StructDefinitionIndex::new(0)), GasCost::new(41, 1)),
(
ExistsGenericDeprecated(StructDefInstantiationIndex::new(0)),
GasCost::new(34, 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use move_core_types::{
language_storage::ModuleId,
vm_status::StatusCode,
};
#[cfg(feature = "gas-profiler")]

use move_vm_profiler::GasProfiler;
use move_vm_types::{
gas::{GasMeter, SimpleInstruction},
Expand Down Expand Up @@ -179,7 +179,7 @@ pub struct GasStatus<'a> {
instructions_executed: u64,
instructions_next_tier_start: Option<u64>,
instructions_current_tier_mult: u64,
#[cfg(feature = "gas-profiler")]

profiler: Option<GasProfiler>,
}

Expand Down Expand Up @@ -210,7 +210,6 @@ impl<'a> GasStatus<'a> {
stack_height_next_tier_start,
stack_size_next_tier_start,
instructions_next_tier_start,
#[cfg(feature = "gas-profiler")]
profiler: None,
}
}
Expand All @@ -235,7 +234,6 @@ impl<'a> GasStatus<'a> {
stack_height_next_tier_start: None,
stack_size_next_tier_start: None,
instructions_next_tier_start: None,
#[cfg(feature = "gas-profiler")]
profiler: None,
}
}
Expand Down Expand Up @@ -702,12 +700,10 @@ impl<'b> GasMeter for GasStatus<'b> {
self.gas_left
}

#[cfg(feature = "gas-profiler")]
fn get_profiler_mut(&mut self) -> Option<&mut GasProfiler> {
self.profiler.as_mut()
}

#[cfg(feature = "gas-profiler")]
fn set_profiler(&mut self, profiler: GasProfiler) {
self.profiler = Some(profiler);
}
Expand Down
6 changes: 1 addition & 5 deletions external-crates/move/crates/move-vm-types/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use move_core_types::{
gas_algebra::{InternalGas, NumArgs, NumBytes},
language_storage::ModuleId,
};
#[cfg(feature = "gas-profiler")]

use move_vm_profiler::GasProfiler;

/// Enum of instructions that do not need extra information for gas metering.
Expand Down Expand Up @@ -187,10 +187,8 @@ pub trait GasMeter {
/// Returns the gas left
fn remaining_gas(&self) -> InternalGas;

#[cfg(feature = "gas-profiler")]
fn get_profiler_mut(&mut self) -> Option<&mut GasProfiler>;

#[cfg(feature = "gas-profiler")]
fn set_profiler(&mut self, profiler: GasProfiler);
}

Expand Down Expand Up @@ -364,11 +362,9 @@ impl GasMeter for UnmeteredGasMeter {
InternalGas::new(u64::MAX)
}

#[cfg(feature = "gas-profiler")]
fn get_profiler_mut(&mut self) -> Option<&mut GasProfiler> {
None
}

#[cfg(feature = "gas-profiler")]
fn set_profiler(&mut self, _profiler: GasProfiler) {}
}

0 comments on commit a11250d

Please sign in to comment.