github-actions[bot] commented on code in PR #34354:
URL: https://github.com/apache/doris/pull/34354#discussion_r1587205560
##########
be/src/io/fs/hdfs_file_writer.cpp:
##########
@@ -46,6 +49,54 @@ bvar::Adder<uint64_t>
hdfs_file_being_written("hdfs_file_writer_file_being_writt
static constexpr size_t MB = 1024 * 1024;
+// In practice, we've found that if the import frequency to HDFS is too fast,
+// it can cause an OutOfMemoryError (OOM) in the JVM started by the JNI.
+// For this, we should have a method to monitor how much JVM memory is
currently being used.
+// The HdfsWriteRateLimit class increments a recorded value during hdfsWrite
when writing to HDFS.
+// When hdfsCloseFile is called, all related memory in the JVM will be
invalidated, so the recorded value can be decreased at that time.
+// If the current usage exceeds the maximum set by the user, the current write
will sleep.
+// If the number of sleeps exceeds the number specified by the user, then the
current write is considered to have failed
+class HdfsWriteRateLimit {
+public:
+ HdfsWriteRateLimit()
+ : max_jvm_heap_size(JniUtil::get_max_jni_heap_memory_size()),
+ cur_memory_comsuption(0) {}
+ size_t max_usage() const {
+ return static_cast<size_t>(max_jvm_heap_size *
+
config::max_hdfs_wirter_jni_heap_usage_ratio);
+ }
+ Status acquire_memory(size_t memory_size) {
Review Comment:
warning: method 'acquire_memory' can be made const
[readability-make-member-function-const]
```suggestion
Status acquire_memory(size_t memory_size) const {
```
--
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]