snuyanzin commented on PR #26319:
URL: https://github.com/apache/flink/pull/26319#issuecomment-2747224155

   >It's obviously. I have added the description.
   
   Thanks for updating the description
   however at least for me it is not obvious  even after that update.
   
   I tried to see the difference with help of jmh
   like
   ```java
   @BenchmarkMode(Mode.AverageTime)
   @OutputTimeUnit(TimeUnit.MILLISECONDS)
   @State(Scope.Benchmark)
   @Fork(value = 2, jvmArgs = {"-Xms2G", "-Xmx2G"})
   public class FlinkTest {
   
       public static void main(String[] args) throws RunnerException {
   
           Options opt = new OptionsBuilder()
                   .include(FlinkTest.class.getSimpleName())
                   .build();
   
           new Runner(opt).run();
       }
   
       @State(Scope.Thread)
       public static class MyState {
           public long offset = 10000;
           public long timestamp = 2000;
           public long size = 1234;
           public long slide = 12;
       }
   
       @Benchmark
       @BenchmarkMode(Mode.Throughput)
       public void current(Blackhole blackhole, MyState state) {
           long offset = state.offset;
           long timestamp = state.timestamp;
           long size = state.size;
           long slide = state.slide;
           List<TimeWindow> windows = new ArrayList<>((int) (size / slide));
           long lastStart = TimeWindow.getWindowStartWithOffset(timestamp, 
offset, slide);
           for (long start = lastStart; start > timestamp - size; start -= 
slide) {
               windows.add(new TimeWindow(start, start + size));
           }
           blackhole.consume(windows);
       }
   
       @Benchmark
       @BenchmarkMode(Mode.Throughput)
       public void improved(Blackhole blackhole, MyState state) {
           long offset = state.offset;
           long timestamp = state.timestamp;
           long size = state.size;
           long slide = state.slide;
           List<TimeWindow> windows = new ArrayList<>((int) (size / slide));
           final long lastStart = 
TimeWindow.getWindowStartWithOffset(timestamp, offset, slide);
           final long lower = timestamp - size;
           for (long start = lastStart; start > lower; start -= slide) {
               windows.add(new TimeWindow(start, start + size));
           }
           blackhole.consume(windows);
       }
   
   }
   ```
   
   my results 
   for jdk17
   ```
    Benchmark            Mode  Cnt     Score    Error   Units
    FlinkTest.current   thrpt   10  2309.684 ± 29.933  ops/ms
    FlinkTest.improved  thrpt   10  2296.488 ± 47.739  ops/ms
   ```
    for jdk21
   ```
    Benchmark            Mode  Cnt     Score    Error   Units
    FlinkTest.current   thrpt   10  2257.881 ± 24.168  ops/ms
    FlinkTest.improved  thrpt   10  2270.597 ± 13.188  ops/ms
   ```
   
   so I don't see any significant difference (probably either this optimization 
has been already done by jdk itself or the rest of the code consumes much more 
time so the improvement brings so low benefit that it could be neglected)
   
   Or did I miss anything?


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