StephanEwen commented on a change in pull request #10329: 
[FLINK-12785][StateBackend] RocksDB savepoint recovery can use a lot of 
unmanaged memory
URL: https://github.com/apache/flink/pull/10329#discussion_r354816050
 
 

 ##########
 File path: 
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBWriteBatchWrapper.java
 ##########
 @@ -113,4 +126,16 @@ public void close() throws RocksDBException {
                }
                IOUtils.closeQuietly(batch);
        }
+
+       private void flushIfNeeded() throws RocksDBException {
+               boolean needFlush = batch.count() == capacity || (batchSize > 0 
&& batch.getDataSize() >= batchSize);
+               if (needFlush) {
+                       flush();
+               }
+       }
+
+       @VisibleForTesting
+       long getDataSize() {
+               return batch.getDataSize();
 
 Review comment:
   Sounds fine to just call rocksDB directly, rather than calculating this 
ourselves.
   I woudl also be fine with a more approximate calculation, where we always 
assume 2 or 4 bytes for the length. But this seems minor.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to