github-actions[bot] commented on code in PR #28122:
URL: https://github.com/apache/doris/pull/28122#discussion_r1419979612


##########
be/src/util/mem_info.cpp:
##########
@@ -460,15 +460,29 @@ void MemInfo::init() {
         _s_sys_mem_available_warning_water_mark = 
_s_sys_mem_available_low_water_mark * 2;
     }
 
+    std::ifstream 
sys_transparent_hugepage("/sys/kernel/mm/transparent_hugepage/enabled",
+                                           std::ios::in);
+    std::string hugepage_enable;
+    // If file not exist, getline returns an empty string.
+    getline(sys_transparent_hugepage, hugepage_enable);
+    if (sys_transparent_hugepage.is_open()) sys_transparent_hugepage.close();
+    if (hugepage_enable == "[always] madvise never") {
+        std::cout << "[WARNING!] /sys/kernel/mm/transparent_hugepage/enabled: 
" << hugepage_enable
+                  << ", Doris not recommend turning on THP, which may cause 
the BE process to use "
+                     "more memory and cannot be freed in time. Turn off THP: 
`echo madvise | sudo "
+                     "tee /sys/kernel/mm/transparent_hugepage/enabled`"
+                  << std::endl;
+    }
+
     // Expect vm overcommit memory value to be 1, system will no longer throw 
bad_alloc, memory alloc are always accepted,
     // memory limit check is handed over to Doris Allocator, make sure throw 
exception position is controllable,
     // otherwise bad_alloc can be thrown anywhere and it will be difficult to 
achieve exception safety.
     std::ifstream sys_vm("/proc/sys/vm/overcommit_memory", std::ios::in);
     std::string vm_overcommit;
     getline(sys_vm, vm_overcommit);
     if (sys_vm.is_open()) sys_vm.close();
-    if (std::stoi(vm_overcommit) == 2) {
-        std::cout << "/proc/sys/vm/overcommit_memory: " << vm_overcommit
+    if (vm_overcommit != "" && std::stoi(vm_overcommit) == 2) {

Review Comment:
   warning: the 'empty' method should be used to check for emptiness instead of 
comparing to an empty object [readability-container-size-empty]
   
   ```suggestion
       if (!vm_overcommit.empty() && std::stoi(vm_overcommit) == 2) {
   ```
   <details>
   <summary>Additional context</summary>
   
   **/usr/include/c++/11/bits/basic_string.h:1022:** method 
'basic_string'::empty() defined here
   ```cpp
         empty() const _GLIBCXX_NOEXCEPT
         ^
   ```
   
   </details>
   



-- 
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]

Reply via email to