[ 
https://issues.apache.org/jira/browse/FLINK-6210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15948673#comment-15948673
 ] 

ASF GitHub Bot commented on FLINK-6210:
---------------------------------------

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.


> RocksDB instance should be closed in ListViaMergeSpeedMiniBenchmark
> -------------------------------------------------------------------
>
>                 Key: FLINK-6210
>                 URL: https://issues.apache.org/jira/browse/FLINK-6210
>             Project: Flink
>          Issue Type: Bug
>          Components: State Backends, Checkpointing
>            Reporter: Ted Yu
>            Assignee: fang yong
>            Priority: Minor
>
> rocksDB instance should be closed upon returning from main().
> ListViaRangeSpeedMiniBenchmark has similar issue.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to