github-actions[bot] commented on code in PR #17301:
URL: https://github.com/apache/doris/pull/17301#discussion_r1121548757
##########
be/src/runtime/memory/mem_tracker.h:
##########
@@ -43,6 +43,50 @@ class MemTracker {
int64_t peak_consumption = 0;
};
+ // A counter that keeps track of the current and peak value seen.
+ // Relaxed ordering, not accurate in real time.
+ class MemCounter {
+ public:
+ MemCounter() : _current_value(0), _peak_value(0) {}
+
+ void add(int64_t delta) {
+ _current_value.fetch_add(delta, std::memory_order_relaxed);
+ update_peak();
+ }
+
+ void add_no_update_peak(int64_t delta) {
+ _current_value.fetch_add(delta, std::memory_order_relaxed);
+ }
+
+ bool try_add(int64_t delta, int64_t max) {
+ if (UNLIKELY(_current_value.load(std::memory_order_relaxed) +
delta > max))
+ return false;
Review Comment:
warning: statement should be inside braces
[readability-braces-around-statements]
```suggestion
if (UNLIKELY(_current_value.load(std::memory_order_relaxed) +
delta > max)) {
return false;
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]