@@ -27,6 +27,7 @@ pub struct SystemSettings {
2727 pub profiling_endpoint_collection_enabled : bool ,
2828 pub profiling_experimental_cpu_time_enabled : bool ,
2929 pub profiling_allocation_enabled : bool ,
30+ pub profiling_allocation_sampling_distance : u32 ,
3031 pub profiling_timeline_enabled : bool ,
3132 pub profiling_exception_enabled : bool ,
3233 pub profiling_exception_message_enabled : bool ,
@@ -69,6 +70,7 @@ impl SystemSettings {
6970 profiling_endpoint_collection_enabled : profiling_endpoint_collection_enabled ( ) ,
7071 profiling_experimental_cpu_time_enabled : profiling_experimental_cpu_time_enabled ( ) ,
7172 profiling_allocation_enabled : profiling_allocation_enabled ( ) ,
73+ profiling_allocation_sampling_distance : profiling_allocation_sampling_distance ( ) ,
7274 profiling_timeline_enabled : profiling_timeline_enabled ( ) ,
7375 profiling_exception_enabled : profiling_exception_enabled ( ) ,
7476 profiling_exception_message_enabled : profiling_exception_message_enabled ( ) ,
@@ -137,6 +139,7 @@ impl SystemSettings {
137139 profiling_endpoint_collection_enabled : false ,
138140 profiling_experimental_cpu_time_enabled : false ,
139141 profiling_allocation_enabled : false ,
142+ profiling_allocation_sampling_distance : 0 ,
140143 profiling_timeline_enabled : false ,
141144 profiling_exception_enabled : false ,
142145 profiling_exception_message_enabled : false ,
@@ -352,6 +355,7 @@ pub(crate) enum ConfigId {
352355 ProfilingEndpointCollectionEnabled ,
353356 ProfilingExperimentalCpuTimeEnabled ,
354357 ProfilingAllocationEnabled ,
358+ ProfilingAllocationSamplingDistance ,
355359 ProfilingTimelineEnabled ,
356360 ProfilingExceptionEnabled ,
357361 ProfilingExceptionMessageEnabled ,
@@ -381,6 +385,7 @@ impl ConfigId {
381385 ProfilingEndpointCollectionEnabled => b"DD_PROFILING_ENDPOINT_COLLECTION_ENABLED\0 " ,
382386 ProfilingExperimentalCpuTimeEnabled => b"DD_PROFILING_EXPERIMENTAL_CPU_TIME_ENABLED\0 " ,
383387 ProfilingAllocationEnabled => b"DD_PROFILING_ALLOCATION_ENABLED\0 " ,
388+ ProfilingAllocationSamplingDistance => b"DD_PROFILING_ALLOCATION_SAMPLING_DISTANCE\0 " ,
384389 ProfilingTimelineEnabled => b"DD_PROFILING_TIMELINE_ENABLED\0 " ,
385390 ProfilingExceptionEnabled => b"DD_PROFILING_EXCEPTION_ENABLED\0 " ,
386391 ProfilingExceptionMessageEnabled => b"DD_PROFILING_EXCEPTION_MESSAGE_ENABLED\0 " ,
@@ -425,6 +430,7 @@ lazy_static::lazy_static! {
425430 profiling_endpoint_collection_enabled: false ,
426431 profiling_experimental_cpu_time_enabled: false ,
427432 profiling_allocation_enabled: false ,
433+ profiling_allocation_sampling_distance: u32 :: MAX ,
428434 profiling_timeline_enabled: false ,
429435 profiling_exception_enabled: false ,
430436 profiling_exception_message_enabled: false ,
@@ -443,6 +449,7 @@ lazy_static::lazy_static! {
443449 profiling_endpoint_collection_enabled: true ,
444450 profiling_experimental_cpu_time_enabled: true ,
445451 profiling_allocation_enabled: true ,
452+ profiling_allocation_sampling_distance: 1024 * 4096 ,
446453 profiling_timeline_enabled: true ,
447454 profiling_exception_enabled: true ,
448455 profiling_exception_message_enabled: false ,
@@ -507,6 +514,17 @@ unsafe fn profiling_allocation_enabled() -> bool {
507514 )
508515}
509516
517+ /// # Safety
518+ /// This function must only be called after config has been initialized in
519+ /// rinit, and before it is uninitialized in mshutdown.
520+ unsafe fn profiling_allocation_sampling_distance ( ) -> u32 {
521+ get_system_uint32 (
522+ ProfilingAllocationSamplingDistance ,
523+ DEFAULT_SYSTEM_SETTINGS . profiling_allocation_sampling_distance ,
524+ )
525+ }
526+
527+
510528/// # Safety
511529/// This function must only be called after config has been initialized in
512530/// rinit, and before it is uninitialized in mshutdown.
@@ -696,8 +714,8 @@ unsafe fn profiling_log_level() -> LevelFilter {
696714 }
697715}
698716
699- /// Parses the exception sampling distance and makes sure it is ℤ+ (positive integer > 0)
700- unsafe extern "C" fn parse_exception_sampling_distance_filter (
717+ /// Parses the sampling distance and makes sure it is ℤ+ (positive integer > 0)
718+ unsafe extern "C" fn parse_sampling_distance_filter (
701719 value : ZaiStr ,
702720 decoded_value : * mut zval ,
703721 _persistent : bool ,
@@ -942,6 +960,18 @@ pub(crate) fn minit(module_number: libc::c_int) {
942960 displayer : None ,
943961 env_config_fallback : None ,
944962 } ,
963+ zai_config_entry {
964+ id : transmute :: < ConfigId , u16 > ( ProfilingAllocationSamplingDistance ) ,
965+ name : ProfilingAllocationSamplingDistance . env_var_name ( ) ,
966+ type_ : ZAI_CONFIG_TYPE_CUSTOM ,
967+ default_encoded_value : ZaiStr :: literal ( b"4194304\0 " ) , // crate::allocation::DEFAULT_ALLOCATION_SAMPLING_INTERVAL
968+ aliases : ptr:: null_mut ( ) ,
969+ aliases_count : 0 ,
970+ ini_change : Some ( zai_config_system_ini_change) ,
971+ parser : Some ( parse_sampling_distance_filter) ,
972+ displayer : None ,
973+ env_config_fallback : None ,
974+ } ,
945975 zai_config_entry {
946976 id : transmute :: < ConfigId , u16 > ( ProfilingTimelineEnabled ) ,
947977 name : ProfilingTimelineEnabled . env_var_name ( ) ,
@@ -986,7 +1016,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
9861016 aliases : EXCEPTION_SAMPLING_DISTANCE_ALIASES . as_ptr ( ) ,
9871017 aliases_count : EXCEPTION_SAMPLING_DISTANCE_ALIASES . len ( ) as u8 ,
9881018 ini_change : Some ( zai_config_system_ini_change) ,
989- parser : Some ( parse_exception_sampling_distance_filter ) ,
1019+ parser : Some ( parse_sampling_distance_filter ) ,
9901020 displayer : None ,
9911021 env_config_fallback : None ,
9921022 } ,
0 commit comments