Bound node memory limit by node_memory_limit#354
Conversation
|
Warning Rate limit exceeded@liunyl has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 33 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (5)
WalkthroughThe PR refactors node memory limit handling by moving the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
core/src/data_substrate.cpp (1)
740-742: Potential integer overflow in memory calculation.The expression
meminfo.totalram * meminfo.mem_unitcould overflow on systems with very large memory. Whilememinfo.totalramisunsigned longandmeminfo.mem_unitis typically 1 (bytes) or a small power of 2, on a 32-bit build with PAE or in edge cases, this multiplication before division could overflow.Consider restructuring to divide earlier or use explicit 64-bit arithmetic:
♻️ Suggested fix
- uint32_t mem_limit_mib = - meminfo.totalram * meminfo.mem_unit / (1024 * 1024) * 4 / 5; + uint64_t total_mem_mib = + static_cast<uint64_t>(meminfo.totalram) * meminfo.mem_unit / (1024 * 1024); + uint32_t mem_limit_mib = static_cast<uint32_t>(total_mem_mib * 4 / 5);
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
core/include/data_substrate.hcore/src/data_substrate.cppcore/src/storage_init.cppcore/src/tx_service_init.cppstore_handler/eloq_data_store_service/eloq_store_config.cpp
🧰 Additional context used
🧬 Code graph analysis (1)
core/src/data_substrate.cpp (4)
core/include/data_substrate.h (1)
CheckCommandLineFlagIsDefault(312-323)store_handler/eloq_data_store_service/eloq_store_config.cpp (2)
CheckCommandLineFlagIsDefault(133-145)CheckCommandLineFlagIsDefault(133-133)store_handler/eloq_data_store_service/main.cpp (2)
CheckCommandLineFlagIsDefault(89-101)CheckCommandLineFlagIsDefault(89-89)store_handler/eloq_data_store_service/rocksdb_config.cpp (2)
CheckCommandLineFlagIsDefault(311-323)CheckCommandLineFlagIsDefault(311-311)
🔇 Additional comments (5)
core/include/data_substrate.h (1)
139-139: LGTM!The addition of
node_memory_limit_mbtoCoreConfigcentralizes memory configuration appropriately. This aligns with the PR objective of having the node memory limit bound the total process memory rather than just the data substrate part.core/src/storage_init.cpp (1)
291-292: Verify the intent of modifyingcore_config_.node_memory_limit_mbby reference.The
EloqStoreConfigconstructor takesnode_memory_mbas a non-const reference and subtracts the buffer pool size from it (line 389 ineloq_store_config.cpp). This meanscore_config_.node_memory_limit_mbwill be permanently reduced after this call.If this is intentional (so that the remaining memory is available for tx_service), then this is correct. However, be aware that:
GetCoreConfig()will return the modified value after this point- The log message "Data substrate memory limit" in
tx_service_init.cppwill show the reduced valueIf the original limit should be preserved, consider passing a copy instead.
store_handler/eloq_data_store_service/eloq_store_config.cpp (1)
369-376: Default buffer pool allocation reduced from 50% to 30%.This is a significant behavioral change that reduces the default EloqStore index buffer pool from 50% to 30% of available memory. While this aligns with the PR's goal of better bounding total memory usage, existing deployments relying on the previous default may experience different performance characteristics.
Consider documenting this change in release notes or migration guides to inform users who may need to explicitly configure
eloq_store_index_buffer_pool_sizeto maintain previous behavior.core/src/tx_service_init.cpp (1)
190-196: LGTM!The refactoring to use
core_config_.node_memory_limit_mbinstead of a local gflag correctly centralizes memory configuration. The log message provides useful visibility into the configured memory limit.Note: As mentioned in the
storage_init.cppreview, by this point the value may have been reduced by the EloqStore buffer pool allocation ifInitializeStorageHandlerwas called first. The log accurately reflects the memory available for the data substrate portion.core/src/data_substrate.cpp (1)
721-752: LGTM - Memory limit configuration logic is well-structured.The configuration precedence (command-line flag → config file → auto-detection) is consistent with the pattern used for other configuration values like
core_number. The auto-detection using 80% of system memory with a 2048 MiB floor is a sensible default.One minor observation: the log message at lines 743-746 says "available memory" but shows
totalramwhich is total physical RAM, not necessarily available. This is fine for the intended purpose but could be clarified if needed.
node_memory_limit now bounds the total memory usage of the process instead of only the data substrate part. Eloqstore mem usage is subtracted from the node mem limit.
node_memory_limit now bounds the total memory usage of the process instead of only the data substrate part. Eloqstore mem usage is subtracted from the node mem limit.
Here are some reminders before you submit the pull request
fixes eloqdb/tx_service#issue_id./mtr --suite=mono_main,mono_multi,mono_basicSummary by CodeRabbit
New Features
Configuration Changes
✏️ Tip: You can customize this high-level summary in your review settings.