Github user shixiaogang commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3652#discussion_r108870133
  
    --- Diff: 
flink-contrib/flink-statebackend-rocksdb/src/test/java/org/apache/flink/contrib/streaming/state/benchmark/ListViaMergeSpeedMiniBenchmark.java
 ---
    @@ -50,55 +50,59 @@ public static void main(String[] args) throws Exception 
{
     
                final RocksDB rocksDB = RocksDB.open(options, 
rocksDir.getAbsolutePath());
     
    -           final String key = "key";
    -           final String value = 
"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ7890654321";
    +           try {
    +                   final String key = "key";
    +                   final String value = 
"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ7890654321";
     
    -           final byte[] keyBytes = key.getBytes(StandardCharsets.UTF_8);
    -           final byte[] valueBytes = 
value.getBytes(StandardCharsets.UTF_8);
    +                   final byte[] keyBytes = 
key.getBytes(StandardCharsets.UTF_8);
    +                   final byte[] valueBytes = 
value.getBytes(StandardCharsets.UTF_8);
     
    -           final int num = 50000;
    +                   final int num = 50000;
     
    -           // ----- insert -----
    -           System.out.println("begin insert");
    +                   // ----- insert -----
    +                   System.out.println("begin insert");
     
    -           final long beginInsert = System.nanoTime();
    -           for (int i = 0; i < num; i++) {
    -                   rocksDB.merge(write_options, keyBytes, valueBytes);
    -           }
    -           final long endInsert = System.nanoTime();
    -           System.out.println("end insert - duration: " + ((endInsert - 
beginInsert) / 1_000_000) + " ms");
    +                   final long beginInsert = System.nanoTime();
    +                   for (int i = 0; i < num; i++) {
    +                           rocksDB.merge(write_options, keyBytes, 
valueBytes);
    +                   }
    +                   final long endInsert = System.nanoTime();
    +                   System.out.println("end insert - duration: " + 
((endInsert - beginInsert) / 1_000_000) + " ms");
     
    -           // ----- read (attempt 1) -----
    +                   // ----- read (attempt 1) -----
     
    -           final byte[] resultHolder = new byte[num * (valueBytes.length + 
2)];
    -           final long beginGet1 = System.nanoTime();
    -           rocksDB.get(keyBytes, resultHolder);
    -           final long endGet1 = System.nanoTime();
    +                   final byte[] resultHolder = new byte[num * 
(valueBytes.length + 2)];
    +                   final long beginGet1 = System.nanoTime();
    +                   rocksDB.get(keyBytes, resultHolder);
    +                   final long endGet1 = System.nanoTime();
     
    -           System.out.println("end get - duration: " + ((endGet1 - 
beginGet1) / 1_000_000) + " ms");
    +                   System.out.println("end get - duration: " + ((endGet1 - 
beginGet1) / 1_000_000) + " ms");
     
    -           // ----- read (attempt 2) -----
    +                   // ----- read (attempt 2) -----
     
    -           final long beginGet2 = System.nanoTime();
    -           rocksDB.get(keyBytes, resultHolder);
    -           final long endGet2 = System.nanoTime();
    +                   final long beginGet2 = System.nanoTime();
    +                   rocksDB.get(keyBytes, resultHolder);
    +                   final long endGet2 = System.nanoTime();
     
    -           System.out.println("end get - duration: " + ((endGet2 - 
beginGet2) / 1_000_000) + " ms");
    +                   System.out.println("end get - duration: " + ((endGet2 - 
beginGet2) / 1_000_000) + " ms");
     
    -           // ----- compact -----
    -           System.out.println("compacting...");
    -           final long beginCompact = System.nanoTime();
    -           rocksDB.compactRange();
    -           final long endCompact = System.nanoTime();
    +                   // ----- compact -----
    +                   System.out.println("compacting...");
    +                   final long beginCompact = System.nanoTime();
    +                   rocksDB.compactRange();
    +                   final long endCompact = System.nanoTime();
     
    -           System.out.println("end compaction - duration: " + ((endCompact 
- beginCompact) / 1_000_000) + " ms");
    +                   System.out.println("end compaction - duration: " + 
((endCompact - beginCompact) / 1_000_000) + " ms");
     
    -           // ----- read (attempt 3) -----
    +                   // ----- read (attempt 3) -----
     
    -           final long beginGet3 = System.nanoTime();
    -           rocksDB.get(keyBytes, resultHolder);
    -           final long endGet3 = System.nanoTime();
    +                   final long beginGet3 = System.nanoTime();
    +                   rocksDB.get(keyBytes, resultHolder);
    +                   final long endGet3 = System.nanoTime();
     
    -           System.out.println("end get - duration: " + ((endGet3 - 
beginGet3) / 1_000_000) + " ms");
    +                   System.out.println("end get - duration: " + ((endGet3 - 
beginGet3) / 1_000_000) + " ms");
    +           } finally {
    +                   rocksDB.close();
    --- End diff --
    
    I think it's better to delete the RocksDB's directory here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to