github-actions[bot] commented on code in PR #61326:
URL: https://github.com/apache/doris/pull/61326#discussion_r2985468403
##########
be/src/util/cpu_info.h:
##########
@@ -148,6 +148,10 @@ class CpuInfo {
static std::string debug_string();
+ static long get_cache_size(CacheLevel level) { return cache_sizes_[level];
}
+
+ static long get_cache_line_size(CacheLevel level) { return
cache_line_sizes_[level]; }
+
Review Comment:
Same as above — add `DCHECK(initialized_)` for consistency with other
getters in this class.
##########
be/src/util/cpu_info.h:
##########
@@ -148,6 +148,10 @@ class CpuInfo {
static std::string debug_string();
+ static long get_cache_size(CacheLevel level) { return cache_sizes_[level];
}
+
Review Comment:
**Inconsistency**: Every other public getter in `CpuInfo`
(`hardware_flags()`, `is_supported()`, `cycles_per_ms()`, `num_cores()`,
`model_name()`) includes `DCHECK(initialized_)`. These new getters should
follow the same convention:
```cpp
static long get_cache_size(CacheLevel level) {
DCHECK(initialized_);
return cache_sizes_[level];
}
```
##########
be/src/util/cpu_info.cpp:
##########
@@ -377,28 +380,28 @@ void CpuInfo::_get_cache_info(long
cache_sizes[NUM_CACHE_LEVELS],
}
std::string CpuInfo::debug_string() {
- DCHECK(initialized_);
std::stringstream stream;
- long cache_sizes[NUM_CACHE_LEVELS];
- long cache_line_sizes[NUM_CACHE_LEVELS];
- _get_cache_info(cache_sizes, cache_line_sizes);
+ if (!initialized_) {
+ return stream.str();
Review Comment:
**Coding standards violation**: Per AGENTS.md, "Assert correctness
only—never use defensive programming with `if` or similar constructs." The
original `DCHECK(initialized_)` was correct — if `debug_string()` is called
before `init()`, that's a programming error and should be caught via assertion,
not silently return an empty string.
Please restore `DCHECK(initialized_)` here.
--
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]