logger/src: Removed Simple Metric
Removed the `SimpleMetric` data type, since it wasn't being used
anywhere in the codebase, either for logging or for testing.
@@ -43,39 +43,10 @@ pub trait Metric {
fn count(&self) -> usize;
}
-/// Representation of a metric that is expected to be incremented from a single thread, so it
-/// can use simple loads and stores with no additional synchronization necessities.
-// Loads are currently Relaxed everywhere, because we don't do anything besides
-// logging the retrieved value (their outcome os not used to modify some memory location in a
-// potentially inconsistent manner). There's no way currently to make sure a SimpleMetric is only
-// incremented by a single thread, this has to be enforced via judicious use (although, every
-// non-vCPU related metric is associated with a particular thread, so it shouldn't be that easy
-// to misuse SimpleMetric fields).
-#[derive(Default)]
-pub struct SimpleMetric(AtomicUsize);
-
-impl Metric for SimpleMetric {
- fn add(&self, value: usize) {
- let count = &self.0;
- count.store(count.load(Ordering::Relaxed) + value, Ordering::Relaxed);
- }
-
- fn count(&self) -> usize {
- self.0.load(Ordering::Relaxed)
- }
-}
-
-impl Serialize for SimpleMetric {
- fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
- // There's no serializer.serialize_usize().
- serializer.serialize_u64(self.0.load(Ordering::Relaxed) as u64)
- }
-}
-
/// Representation of a metric that is expected to be incremented from more than one thread, so more
/// synchronization is necessary.
// It's currently used for vCPU metrics. An alternative here would be
-// to have one instance of every metric for each thread (like a per-thread SimpleMetric), and to
+// to have one instance of every metric for each thread, and to
// aggregate them when logging. However this probably overkill unless we have a lot of vCPUs
// incrementing metrics very often. Still, it's there if we ever need it :-s
#[derive(Default)]
@@ -451,15 +422,7 @@ mod tests {
#[test]
fn test_metric() {
- let m1 = SimpleMetric::default();
-
- m1.inc();
- m1.inc();
- m1.add(5);
- m1.inc();
-
- assert_eq!(m1.count(), 8);
-
+ // Test SharedMetric.
let m2 = Arc::new(SharedMetric::default());
// We're going to create a number of threads that will attempt to increase this metric
