alamb commented on a change in pull request #1691:
URL: https://github.com/apache/arrow-datafusion/pull/1691#discussion_r795069168
##########
File path: datafusion/src/execution/memory_manager.rs
##########
@@ -270,25 +270,35 @@ impl MemoryManager {
requesters: Arc::new(Mutex::new(HashSet::new())),
pool_size,
requesters_total: Arc::new(Mutex::new(0)),
- trackers_total: Arc::new(Mutex::new(0)),
+ trackers_total: AtomicUsize::new(0),
cv: Condvar::new(),
})
}
}
}
fn get_tracker_total(&self) -> usize {
- *self.trackers_total.lock().unwrap()
+ self.trackers_total.load(Ordering::SeqCst)
}
pub(crate) fn grow_tracker_usage(&self, delta: usize) {
- *self.trackers_total.lock().unwrap() += delta;
+ self.trackers_total.fetch_add(delta, Ordering::SeqCst);
}
pub(crate) fn shrink_tracker_usage(&self, delta: usize) {
- let mut total = self.trackers_total.lock().unwrap();
- assert!(*total >= delta);
- *total -= delta;
+ let update =
+ self.trackers_total
+ .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| {
Review comment:
This PR is ready to go I think -- we can always keep iterating in the
next one. Sorry for the delay in merging @yjshen
--
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]