Skip to content

Commit

Permalink
Rename gas-profiler feature flag to tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
tzakian committed Oct 29, 2024
1 parent e8690c5 commit 2e900f8
Show file tree
Hide file tree
Showing 45 changed files with 147 additions and 147 deletions.
4 changes: 2 additions & 2 deletions crates/sui-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ fn main() {
// TODO: re-enable after we figure out how to eliminate crashes in prod because of this.
// ProtocolConfig::poison_get_for_min_version();

move_vm_profiler::gas_profiler_feature_enabled! {
panic!("Cannot run the sui-node binary with gas-profiler feature enabled");
move_vm_profiler::tracing_feature_enabled! {
panic!("Cannot run the sui-node binary with tracing feature enabled");
}

let args = Args::parse();
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ harness = false
[features]
default = []
test-utils = []
gas-profiler = [
"move-vm-profiler/gas-profiler",
"move-vm-test-utils/gas-profiler",
tracing = [
"move-vm-profiler/tracing",
"move-vm-test-utils/tracing",
]
fuzzing = ["move-core-types/fuzzing"]
6 changes: 3 additions & 3 deletions crates/sui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ name = "ptb_files_tests"
harness = false

[features]
gas-profiler = [
"sui-types/gas-profiler",
"sui-execution/gas-profiler",
tracing = [
"sui-types/tracing",
"sui-execution/tracing",
]
6 changes: 3 additions & 3 deletions crates/sui/src/client_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,10 @@ impl SuiClientCommands {
tx_digest,
profile_output,
} => {
move_vm_profiler::gas_profiler_feature_disabled! {
move_vm_profiler::tracing_feature_disabled! {
bail!(
"gas-profiler feature is not enabled, rebuild or reinstall with \
--features gas-profiler"
"tracing feature is not enabled, rebuild or reinstall with \
--features tracing"
);
};

Expand Down
16 changes: 8 additions & 8 deletions crates/sui/src/unit_tests/profiler_tests.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

/// This test exists to make sure that the feature gating for all the code under `gas-profiler`
/// remains fully connected such that if and only if we enable the feature here, the `gas-profiler`
/// This test exists to make sure that the feature gating for all the code under `tracing`
/// remains fully connected such that if and only if we enable the feature here, the `tracing`
/// feature gets enabled anywhere.
///
/// If this test fails, check for the following.
///
/// Any crate that has code decorated with #[cfg(feature = "gas-profiler")] needs to have
/// a feature declared in its Cargo.toml named `gas-profiler`. If moving / refactoring code with
/// Any crate that has code decorated with #[cfg(feature = "tracing")] needs to have
/// a feature declared in its Cargo.toml named `tracing`. If moving / refactoring code with
/// this decorator from a crate to a different crate, it is likely needed to copy over some of the
/// feature declaration defined in the original crate. Also ensure we do not include the feature in
/// any dependency of the dependencies section so that the feature won't get partially enabled as
Expand All @@ -21,18 +21,18 @@
/// defined in all the other crates that the decorated code in the current crate depends on.
///
/// Note this crate will always have the feature enabled in testing due to the addition of
/// `sui = { path = ".", features = ["gas-profiler"] }` to our dev-dependencies.
/// `sui = { path = ".", features = ["tracing"] }` to our dev-dependencies.
#[cfg(feature = "gas-profiler")]
#[cfg(feature = "tracing")]
#[test]
fn test_macro_shows_feature_enabled() {
move_vm_profiler::gas_profiler_feature_disabled! {
move_vm_profiler::tracing_feature_disabled! {
panic!("gas profile feature graph became disconnected");
}
}

#[ignore]
#[cfg(feature = "gas-profiler")]
#[cfg(feature = "tracing")]
#[tokio::test(flavor = "multi_thread")]
async fn test_profiler() {
use std::fs;
Expand Down
2 changes: 1 addition & 1 deletion external-crates/move/crates/move-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ harness = false

[features]
tiered-gas = ["move-vm-test-utils/tiered-gas"]
gas-profiler = ["move-vm-runtime/gas-profiler"]
tracing = ["move-vm-runtime/tracing"]
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn run(
// script fun. parse module, extract script ID to pass to VM
let module = CompiledModule::deserialize_with_defaults(&bytecode)
.map_err(|e| anyhow!("Error deserializing module: {:?}", e))?;
move_vm_profiler::gas_profiler_feature_enabled! {
move_vm_profiler::tracing_feature_enabled! {
use move_vm_profiler::GasProfiler;
use move_vm_types::gas::GasMeter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::Path;

#[allow(unused_variables)]
fn run_all(args_path: &Path) -> datatest_stable::Result<()> {
#[cfg(feature = "gas-profiler")]
#[cfg(feature = "tracing")]
{
use move_cli::sandbox::commands::test;
use std::path::PathBuf;
Expand Down
2 changes: 1 addition & 1 deletion external-crates/move/crates/move-unit-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ name = "move_unit_test_testsuite"
harness = false

[features]
gas-profiler = []
tracing = []
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl SharedTestingConfig {
let mut session =
move_vm.new_session_with_extensions(&self.starting_storage_state, extensions);
let mut gas_meter = GasStatus::new(&self.cost_table, Gas::new(self.execution_bound));
move_vm_profiler::gas_profiler_feature_enabled! {
move_vm_profiler::tracing_feature_enabled! {
use move_vm_profiler::GasProfiler;
use move_vm_types::gas::GasMeter;
gas_meter.set_profiler(GasProfiler::init_default_cfg(
Expand Down
2 changes: 1 addition & 1 deletion external-crates/move/crates/move-vm-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ move-binary-format.workspace = true
once_cell.workspace = true

[features]
gas-profiler = []
tracing = []
10 changes: 5 additions & 5 deletions external-crates/move/crates/move-vm-config/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
use crate::verifier::{VerifierConfig, DEFAULT_MAX_CONSTANT_VECTOR_LEN};
use move_binary_format::binary_config::BinaryConfig;
use move_binary_format::file_format_common::VERSION_MAX;
#[cfg(feature = "gas-profiler")]
#[cfg(feature = "tracing")]
use once_cell::sync::Lazy;

#[cfg(feature = "gas-profiler")]
#[cfg(feature = "tracing")]
const MOVE_VM_PROFILER_ENV_VAR_NAME: &str = "MOVE_VM_PROFILE";

#[cfg(feature = "gas-profiler")]
#[cfg(feature = "tracing")]
static PROFILER_ENABLED: Lazy<bool> =
Lazy::new(|| std::env::var(MOVE_VM_PROFILER_ENV_VAR_NAME).is_ok());

Expand Down Expand Up @@ -88,7 +88,7 @@ pub struct VMProfilerConfig {
pub use_long_function_name: bool,
}

#[cfg(feature = "gas-profiler")]
#[cfg(feature = "tracing")]
impl std::default::Default for VMProfilerConfig {
fn default() -> Self {
Self {
Expand All @@ -99,7 +99,7 @@ impl std::default::Default for VMProfilerConfig {
}
}

#[cfg(feature = "gas-profiler")]
#[cfg(feature = "tracing")]
impl VMProfilerConfig {
pub fn get_default_config_if_enabled() -> Option<VMProfilerConfig> {
if *PROFILER_ENABLED {
Expand Down
10 changes: 5 additions & 5 deletions external-crates/move/crates/move-vm-integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ move-ir-to-bytecode.workspace = true

[features]
default = []
gas-profiler = [
"move-vm-config/gas-profiler",
"move-vm-runtime/gas-profiler",
"move-vm-profiler/gas-profiler",
"move-vm-test-utils/gas-profiler",
tracing = [
"move-vm-config/tracing",
"move-vm-runtime/tracing",
"move-vm-profiler/tracing",
"move-vm-test-utils/tracing",
]

[[bin]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use move_core_types::{
language_storage::{ModuleId, StructTag, TypeTag},
vm_status::StatusCode,
};
#[cfg(feature = "gas-profiler")]
#[cfg(feature = "tracing")]
use move_vm_profiler::GasProfiler;
use move_vm_runtime::{
move_vm::MoveVM,
Expand All @@ -33,7 +33,7 @@ use move_vm_test_utils::{
gas_schedule::{Gas, GasStatus, INITIAL_COST_SCHEDULE},
InMemoryStorage,
};
#[cfg(feature = "gas-profiler")]
#[cfg(feature = "tracing")]
use move_vm_types::gas::GasMeter;
use std::time::Instant;

Expand Down Expand Up @@ -555,7 +555,7 @@ fn run_with_module(
.into_iter()
.map(|tag| session.load_type(&tag))
.collect::<VMResult<Vec<_>>>();
move_vm_profiler::gas_profiler_feature_enabled! {
move_vm_profiler::tracing_feature_enabled! {
gas.set_profiler(GasProfiler::init(
&session.vm_config().profiler_config,
entry_name.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion external-crates/move/crates/move-vm-profiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ tracing.workspace = true
move-vm-config.workspace = true

[features]
gas-profiler = ["move-vm-config/gas-profiler"]
tracing = ["move-vm-config/tracing"]
Loading

0 comments on commit 2e900f8

Please sign in to comment.