Skip to content

Commit

Permalink
move feature decision to config
Browse files Browse the repository at this point in the history
  • Loading branch information
realFlowControl committed Dec 6, 2023
1 parent 3d127bc commit 6a6ca5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
15 changes: 9 additions & 6 deletions profiling/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,42 +206,45 @@ pub(crate) unsafe fn profiling_enabled() -> bool {
/// This function must only be called after config has been initialized in
/// rinit, and before it is uninitialized in mshutdown.
pub(crate) unsafe fn profiling_experimental_features_enabled() -> bool {
get_bool(ProfilingExperimentalFeaturesEnabled, false)
profiling_enabled() && get_bool(ProfilingExperimentalFeaturesEnabled, false)
}

/// # Safety
/// This function must only be called after config has been initialized in
/// rinit, and before it is uninitialized in mshutdown.
pub(crate) unsafe fn profiling_endpoint_collection_enabled() -> bool {
get_bool(ProfilingEndpointCollectionEnabled, true)
profiling_enabled() && get_bool(ProfilingEndpointCollectionEnabled, true)
}

/// # Safety
/// This function must only be called after config has been initialized in
/// rinit, and before it is uninitialized in mshutdown.
pub(crate) unsafe fn profiling_experimental_cpu_time_enabled() -> bool {
get_bool(ProfilingExperimentalCpuTimeEnabled, true)
profiling_experimental_features_enabled()
|| profiling_enabled() && get_bool(ProfilingExperimentalCpuTimeEnabled, true)
}

/// # Safety
/// This function must only be called after config has been initialized in
/// rinit, and before it is uninitialized in mshutdown.
pub(crate) unsafe fn profiling_allocation_enabled() -> bool {
get_bool(ProfilingAllocationEnabled, true)
profiling_enabled() && get_bool(ProfilingAllocationEnabled, true)
}

/// # Safety
/// This function must only be called after config has been initialized in
/// rinit, and before it is uninitialized in mshutdown.
pub(crate) unsafe fn profiling_experimental_timeline_enabled() -> bool {
get_bool(ProfilingExperimentalTimelineEnabled, false)
profiling_experimental_features_enabled()
|| profiling_enabled() && get_bool(ProfilingExperimentalTimelineEnabled, false)
}

/// # Safety
/// This function must only be called after config has been initialized in
/// rinit, and before it is uninitialized in mshutdown.
pub(crate) unsafe fn profiling_experimental_exception_enabled() -> bool {
get_bool(ProfilingExperimentalExceptionEnabled, false)
profiling_experimental_features_enabled()
|| profiling_enabled() && get_bool(ProfilingExperimentalExceptionEnabled, false)
}

/// # Safety
Expand Down
20 changes: 7 additions & 13 deletions profiling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,20 +478,14 @@ extern "C" fn rinit(_type: c_int, _module_number: c_int) -> ZendResult {
log_level,
output_pprof,
) = unsafe {
let profiling_enabled = config::profiling_enabled();
let profiling_experimental_features_enabled =
profiling_enabled && config::profiling_experimental_features_enabled();
(
profiling_enabled,
profiling_experimental_features_enabled,
profiling_enabled && config::profiling_endpoint_collection_enabled(),
profiling_experimental_features_enabled
|| profiling_enabled && config::profiling_experimental_cpu_time_enabled(),
profiling_enabled && config::profiling_allocation_enabled(),
profiling_experimental_features_enabled
|| profiling_enabled && config::profiling_experimental_timeline_enabled(),
profiling_experimental_features_enabled
|| profiling_enabled && config::profiling_experimental_exception_enabled(),
config::profiling_enabled(),
config::profiling_experimental_features_enabled(),
config::profiling_endpoint_collection_enabled(),
config::profiling_experimental_cpu_time_enabled(),
config::profiling_allocation_enabled(),
config::profiling_experimental_timeline_enabled(),
config::profiling_experimental_exception_enabled(),
config::profiling_experimental_exception_sampling_distance(),
config::profiling_log_level(),
config::profiling_output_pprof(),
Expand Down

0 comments on commit 6a6ca5f

Please sign in to comment.