imbajin commented on code in PR #3355:
URL: https://github.com/apache/hugegraph/pull/3355#discussion_r4279250750


##########
hugegraph-store/hg-store-node/src/main/java/org/apache/hugegraph/store/node/AppConfig.java:
##########
@@ -104,15 +105,11 @@ public void init() {
         }
 
         Map<String, String> rocksdb = rocksdbConfig.rocksdb;
-        if (!rocksdb.containsKey("total_memory_size")
-            || "0".equals(rocksdb.get("total_memory_size"))) {
-            rocksdb.put("total_memory_size", Long.toString(rt.maxMemory()));
-        }
-        long totalMemory = 
Long.parseLong(rocksdbConfig.rocksdb.get("total_memory_size"));
+        long totalMemory = 
RocksdbMemoryBudget.resolve(rocksdb.get(RocksdbMemoryBudget.KEY));
+        rocksdb.put(RocksdbMemoryBudget.KEY, Long.toString(totalMemory));
         if (raft.getDisruptorBufferSize() == 0) {

Review Comment:
   [P2] Keep the derived write buffer above RocksDB's minimum
   
   The smaller automatic budget makes the existing omitted/zero 
`write_buffer_size` fallback invalid. For a 4 GiB container with `-Xmx1g`, 
`-XX:MaxDirectMemorySize=512m`, `total_memory_size: 0` and `write_buffer_size: 
0`, `resolve()` returns 536870912 bytes; the fallback below then derives 536870 
bytes. `RocksDBOptions.MEMTABLE_SIZE` requires at least 1048576 bytes, so Store 
initialization rejects this configuration through `HgStoreNodeService.init()` → 
`RaftRocksdbOptions.initRocksdbGlobalConfig()` → 
`BusinessHandlerImpl.initRocksdb()` → `new HugeConfig(...)`.
   
   Before this change, the same automatic configuration used the 1 GiB heap and 
derived 1073741 bytes, which passed. Omitting `write_buffer_size` takes the 
same path; the shipped 32000000 value masks it. Please clamp the derived value 
to RocksDB's minimum and add a regression covering the AppConfig-to-HugeConfig 
initialization path. This is source-verified with exact arithmetic, not an 
independently executed startup test.



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