summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2024-04-08 16:49:34 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-04-08 16:49:34 +0000
commit4fb32f94e1e9a437aec6ff8f4de3eb78f3d17dee (patch)
tree8fbcce23f1153ce38f0c589bad0ae29370080074
parent86ff8847067916ba6569fe7229f2d67215f75ca5 (diff)
parent0507c803adbe7bbe7090b9268b7cac4eb7d550a6 (diff)
downloadextras-4fb32f94e1e9a437aec6ff8f4de3eb78f3d17dee.tar.gz
Merge "Do not reset profcollectd on sampling_period change" into main
-rw-r--r--profcollectd/libprofcollectd/config.rs10
-rw-r--r--profcollectd/libprofcollectd/scheduler.rs6
2 files changed, 10 insertions, 6 deletions
diff --git a/profcollectd/libprofcollectd/config.rs b/profcollectd/libprofcollectd/config.rs
index 87242489..d686cbaa 100644
--- a/profcollectd/libprofcollectd/config.rs
+++ b/profcollectd/libprofcollectd/config.rs
@@ -57,8 +57,6 @@ pub struct Config {
pub build_fingerprint: String,
/// Interval between collections.
pub collection_interval: Duration,
- /// Length of time each collection lasts for.
- pub sampling_period: Duration,
/// An optional filter to limit which binaries to or not to profile.
pub binary_filter: String,
/// Maximum size of the trace directory.
@@ -75,7 +73,6 @@ impl Config {
"collection_interval",
600,
)?),
- sampling_period: Duration::from_millis(get_device_config("sampling_period", 500)?),
binary_filter: get_device_config("binary_filter", DEFAULT_BINARY_FILTER.to_string())?,
max_trace_limit: get_device_config(
"max_trace_limit",
@@ -123,6 +120,13 @@ where
Ok(T::from_str(&config)?)
}
+pub fn get_sampling_period() -> Duration {
+ let default_period = 500;
+ Duration::from_millis(
+ get_device_config("sampling_period", default_period).unwrap_or(default_period),
+ )
+}
+
fn get_property<T>(key: &str, default_value: T) -> Result<T>
where
T: FromStr + ToString,
diff --git a/profcollectd/libprofcollectd/scheduler.rs b/profcollectd/libprofcollectd/scheduler.rs
index 5558f581..8695f57c 100644
--- a/profcollectd/libprofcollectd/scheduler.rs
+++ b/profcollectd/libprofcollectd/scheduler.rs
@@ -25,7 +25,7 @@ use std::sync::Mutex;
use std::thread;
use std::time::{Duration, Instant};
-use crate::config::{Config, LOG_FILE, PROFILE_OUTPUT_DIR, TRACE_OUTPUT_DIR};
+use crate::config::{get_sampling_period, Config, LOG_FILE, PROFILE_OUTPUT_DIR, TRACE_OUTPUT_DIR};
use crate::trace_provider::{self, TraceProvider};
use anyhow::{anyhow, ensure, Context, Result};
@@ -73,7 +73,7 @@ impl Scheduler {
trace_provider.lock().unwrap().trace(
&TRACE_OUTPUT_DIR,
"periodic",
- &config.sampling_period,
+ &get_sampling_period(),
&config.binary_filter,
);
}
@@ -100,7 +100,7 @@ impl Scheduler {
trace_provider.lock().unwrap().trace(
&TRACE_OUTPUT_DIR,
tag,
- &config.sampling_period,
+ &get_sampling_period(),
&config.binary_filter,
);
}