You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "beliefer (via GitHub)" <gi...@apache.org> on 2025/03/19 07:43:23 UTC
[PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
beliefer opened a new pull request, #26319:
URL: https://github.com/apache/flink/pull/26319
## What is the purpose of the change
This PR aim to avoid duplicate calculations for `SlidingEventTimeWindows`.
## Brief change log
Avoid duplicate calculations for `SlidingEventTimeWindows`
## Verifying this change
This change is already covered by existing tests, such as *(SlidingEventTimeWindowsTest)*.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (no)
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26319:
URL: https://github.com/apache/flink/pull/26319#discussion_r2003630811
##########
flink-runtime/src/main/java/org/apache/flink/streaming/api/windowing/assigners/SlidingEventTimeWindows.java:
##########
@@ -71,7 +71,8 @@ public Collection<TimeWindow> assignWindows(
if (timestamp > Long.MIN_VALUE) {
List<TimeWindow> windows = new ArrayList<>((int) (size / slide));
long lastStart = TimeWindow.getWindowStartWithOffset(timestamp, offset, slide);
- for (long start = lastStart; start > timestamp - size; start -= slide) {
+ long lower = timestamp - size;
Review Comment:
nit: can we add final to this and `long lastStart`
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #26319:
URL: https://github.com/apache/flink/pull/26319#issuecomment-4333103925
This PR is being marked as stale since it has not had any activity in the last 90 days.
If you would like to keep this PR alive, please leave a comment asking for a review.
If the PR has merge conflicts, update it with the latest from the base branch.
If you are having difficulty finding a reviewer, please reach out to the
community, contact details can be found here: https://flink.apache.org/what-is-flink/community/
If this PR is no longer valid or desired, please feel free to close it.
If no activity occurs in the next 30 days, it will be automatically closed.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on PR #26319:
URL: https://github.com/apache/flink/pull/26319#issuecomment-2747462543
On the other hand, avoid duplicate expressions is always a best practices know for anybody.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on PR #26319:
URL: https://github.com/apache/flink/pull/26319#issuecomment-2768943771
@snuyanzin Could you have time to review again ? This Improvement is just avoid the duplicate calculation which is not have a very strong improvement in performance.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on PR #26319:
URL: https://github.com/apache/flink/pull/26319#issuecomment-2746720571
> Probably I missed something however can you please describe what is the issue here and how we could check that it is gone after this commit?
It's obviously. I have added the description.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on PR #26319:
URL: https://github.com/apache/flink/pull/26319#issuecomment-2736322387
ping @aljoscha @StephanEwen cc @1996fanrui @davidradl
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin merged PR #26319:
URL: https://github.com/apache/flink/pull/26319
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on PR #26319:
URL: https://github.com/apache/flink/pull/26319#issuecomment-2747459253
@snuyanzin The benchmark ignored some questions. Obviously, the overhead of minus is very small. Otherwise, we should doubt the availability of JAVA. Second, The JVM will optimize it after interpretation.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on PR #26319:
URL: https://github.com/apache/flink/pull/26319#issuecomment-4334079812
@snuyanzin @1996fanrui @davidradl @nilmadhab Thank you all!
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "nilmadhab (via GitHub)" <gi...@apache.org>.
nilmadhab commented on PR #26319:
URL: https://github.com/apache/flink/pull/26319#issuecomment-2735679717
LGTM
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on PR #26319:
URL: https://github.com/apache/flink/pull/26319#issuecomment-2754319419
ping @aljoscha @StephanEwen
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #26319:
URL: https://github.com/apache/flink/pull/26319#issuecomment-2735654752
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "f8f9085734eeda119712af756b504dd4775c7985",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "f8f9085734eeda119712af756b504dd4775c7985",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* f8f9085734eeda119712af756b504dd4775c7985 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on code in PR #26319:
URL: https://github.com/apache/flink/pull/26319#discussion_r2004665307
##########
flink-runtime/src/main/java/org/apache/flink/streaming/api/windowing/assigners/SlidingEventTimeWindows.java:
##########
@@ -71,7 +71,8 @@ public Collection<TimeWindow> assignWindows(
if (timestamp > Long.MIN_VALUE) {
List<TimeWindow> windows = new ArrayList<>((int) (size / slide));
long lastStart = TimeWindow.getWindowStartWithOffset(timestamp, offset, slide);
- for (long start = lastStart; start > timestamp - size; start -= slide) {
+ long lower = timestamp - size;
Review Comment:
Done!
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-37510] Avoid duplicate calculations for SlidingEventTimeWindows [flink]
Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on PR #26319:
URL: https://github.com/apache/flink/pull/26319#issuecomment-2893528807
ping @aljoscha @JunRuiLee @XComp @yunfengzhou-hub @reswqa
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org