yjshen commented on issue #1569:
URL:
https://github.com/apache/arrow-datafusion/issues/1569#issuecomment-1019799926
I want to propose adding a new kind of Metric: `Gauge`, which is much like
the current `Count` but provide two extra methods `sub` and `set`:
```rust
#[derive(Debug, Clone)]
pub struct Gauge {
/// value of the metric gauge
value: std::sync::Arc<AtomicUsize>,
}
impl Gauge {
/// create a new gauge
pub fn new() -> Self {
Self {
value: Arc::new(AtomicUsize::new(0)),
}
}
/// Add `n` to the metric's value
pub fn add(&self, n: usize) {
// relaxed ordering for operations on `value` poses no issues
// we're purely using atomic ops with no associated memory ops
self.value.fetch_add(n, Ordering::Relaxed);
}
/// Substract `n` from the metric's value
pub fn sub(&self, n: usize) {
}
/// set the metric's value to `n`
pub fn set(&self, n: usize) {
}
/// Get the current value
pub fn value(&self) -> usize {
self.value.load(Ordering::Relaxed)
}
}
```
And by adding `CurrentMemoryUsage(Gauge)` to `BaselineMetrics`, we could
achieve the goal of memory tracking more easily.
Besides, a `MaxMemoryUsage(Gauge)` could be used, providing more
configuration optimization info to users.
cc @alamb @houqp for more thoughts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]