Zakelly commented on code in PR #83:
URL: https://github.com/apache/flink-benchmarks/pull/83#discussion_r1430468167


##########
src/main/java/org/apache/flink/state/benchmark/ttl/TtlStateBenchmarkBase.java:
##########
@@ -0,0 +1,48 @@
+package org.apache.flink.state.benchmark.ttl;
+
+import org.apache.flink.api.common.state.StateDescriptor;
+import org.apache.flink.api.common.state.StateTtlConfig;
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.state.benchmark.StateBenchmarkBase;
+import org.openjdk.jmh.annotations.Param;
+
+import java.util.concurrent.TimeUnit;
+
+/** The base class for state tests with ttl. */
+public class TtlStateBenchmarkBase extends StateBenchmarkBase {
+
+    /** The expired time of ttl. */
+    public enum ExpiredTimeOptions {
+
+        /** 5 seconds. */
+        Seconds5(5000),

Review Comment:
   I think it is better to manipulate the `TtlTimeProvider` to finely control 
the number of keys eliminated in each iteration. So I customize the 
`TtlTimeProvider` and provide an option for the percentage of keys that expired 
per iteration. This option will affect the result of test especially in 
`valueGet`. Here's a running test:
   ```
   # Benchmark: 
org.apache.flink.state.benchmark.ttl.TtlValueStateBenchmark.valueGet
   # Parameters: (backendType = HEAP, expiredOption = 
ExpirePercent3PerIteration, stateVisibility = NeverReturnExpired, updateType = 
OnCreateAndWrite)
   
   # Run progress: 0.00% complete, ETA 00:12:00
   # Fork: 1 of 3
   # Warmup Iteration   1: 2993.246 ops/ms
   # Warmup Iteration   2: 3520.954 ops/ms
   # Warmup Iteration   3: 3640.884 ops/ms
   # Warmup Iteration   4: 3643.386 ops/ms
   # Warmup Iteration   5: 3776.677 ops/ms
   # Warmup Iteration   6: 3739.375 ops/ms
   # Warmup Iteration   7: 3903.434 ops/ms
   # Warmup Iteration   8: 3877.286 ops/ms
   # Warmup Iteration   9: 3913.663 ops/ms
   # Warmup Iteration  10: 4093.471 ops/ms
   Iteration   1: 4117.018 ops/ms
   Iteration   2: 4255.166 ops/ms
   Iteration   3: 4338.564 ops/ms
   Iteration   4: 4439.571 ops/ms
   Iteration   5: 4603.235 ops/ms
   Iteration   6: 4735.039 ops/ms
   Iteration   7: 4896.946 ops/ms
   Iteration   8: 5153.644 ops/ms
   Iteration   9: 5429.196 ops/ms
   Iteration  10: 5772.806 ops/ms
   ```
   As we can see, as the key expires, the test results increase iteration by 
iteration. I pick 3% for a predefined value, since there are 20 iterations in 
each test and we cannot let all the keys expire. WDYT? @Myasuka 
   
   



-- 
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]

Reply via email to