zookeeper-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] BELUGABEHR commented on issue #888: ZOOKEEPER-3347: Improve PathTrie Consistency
Date Mon, 15 Jul 2019 15:05:38 GMT
BELUGABEHR commented on issue #888: ZOOKEEPER-3347: Improve PathTrie Consistency
URL: https://github.com/apache/zookeeper/pull/888#issuecomment-511440821
 
 
   @anmolnar OK. I created a micro-test.
   
   ```
   public class PathTrieBenchmark {
   
     public static void main(String[] args) throws Exception {
       org.openjdk.jmh.Main.main(args);
     }
   
     @Benchmark
     @OperationsPerInvocation(6)
     @Threads(4)
     public void readOnly(final TestState state, final Blackhole blackHole) {
       state.allPaths
           .forEach(p -> blackHole.consume(state.pathTrie.findMaxPrefix(p)));
     }
   
     @State(Scope.Thread)
     public static class TestState {
       PathTrieTrunk pathTrie;
       List<String> allPaths;
   
       public TestState() {
         super();
       }
   
       /**
        * Setup each trial
        *
        * @throws IOException Could not setup test data
        */
       @Setup(Level.Trial)
       public void doSetupTrial() throws Exception {
         this.pathTrie = new PathTrieTrunk();
         this.pathTrie.addPath("/hive/db1/table1/partition1");
         this.pathTrie.addPath("/hive/db1/table1/partition2");
         this.pathTrie.addPath("/hive/db1/table1/partition3");
         this.pathTrie.addPath("/hive/db1/table2/partition1");
         this.pathTrie.addPath("/hive/db1/table2/partition2");
         this.pathTrie.addPath("/hive/db2/table1/partition1");
   
         this.allPaths = Arrays.asList("/hive/db1/table1/partition1",
             "/hive/db1/table1/partition2", "/hive/db1/table1/partition3",
             "/hive/db1/table2/partition1", "/hive/db1/table2/partition2",
             "/hive/db2/table1/partition1");
   
         Collections.shuffle(allPaths, new Random(13L));
       }
     }
   ```
   
   My implementation, for a read-only workload, is roughly 50% faster.  This makes sense to
me.  My implementation grabs a single lock during the operation.  The trunk version grabs
many locks per iteration.
   
   ```
   # ZOOKEEPER-3347
   Result "org.apache.zookeeper.common.PathTrieBenchmark.readOnly":
     3150273.933 ±(99.9%) 32031.621 ops/s [Average]
     (min, avg, max) = (2438685.435, 3150273.933, 3321090.289), stdev = 135623.888
     CI (99.9%): [3118242.312, 3182305.553] (assumes normal distribution)
   
   
   # Run complete. Total time: 00:06:49
   
   Benchmark                    Mode  Cnt        Score       Error  Units
   PathTrieBenchmark.readOnly  thrpt  200  3150273.933 ± 32031.621  ops/s
   
   
   # ZOOKEEPER-TRUNK
   Result "org.apache.zookeeper.common.PathTrieBenchmark.readOnly":
     2289729.420 ±(99.9%) 14836.462 ops/s [Average]
     (min, avg, max) = (1778045.008, 2289729.420, 2364358.214), stdev = 62818.511
     CI (99.9%): [2274892.958, 2304565.883] (assumes normal distribution)
   
   
   # Run complete. Total time: 00:06:49
   
   Benchmark                    Mode  Cnt        Score       Error  Units
   PathTrieBenchmark.readOnly  thrpt  200  2289729.420 ± 14836.462  ops/s
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message