Use trigger state to know if a window is new and optimize reads#37574
Use trigger state to know if a window is new and optimize reads#37574arunpandianp wants to merge 21 commits into
Conversation
Summary of ChangesHello @arunpandianp, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces optimizations for state management within Apache Beam's windowing system, specifically targeting new windows. By leveraging trigger state to determine if a window is being processed for the first time, the system can avoid redundant state reads and writes, leading to improved performance, especially in distributed execution environments like Windmill. The changes include adding methods to identify new windows and to mark state as locally empty, along with corresponding logic in the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
baaf7ef to
28957f5
Compare
SentinelBitSetCoder is same as BitSetCoder except that it encodes empty bitset as a single element 0 byte array. This allows checking if the finished bitset is empty or missing. SentinelBitSetCoder and BitSetCoder are state compatible. Both coders can decode encoded bytes from the other coder successfully.
| } | ||
| @Nullable BitSet currentBits = finishedSetState.read(); | ||
| if (currentBits == null || !currentBits.equals(modifiedFinishedSet.getBitSet())) { | ||
| finishedSetState.write(modifiedFinishedSet.getBitSet()); |
There was a problem hiding this comment.
Need to make sure this doesn't cause unbounded state growth with global windows
There was a problem hiding this comment.
IIUC, repeated triggers in global windows will cause unbounded state growth. It can be avoided by differentiating clear vs delete bitset. Added a TODO, will tackle it separately. Since the change is behind an unstable experiment, it is safe to merge.
There was a problem hiding this comment.
I'm not seeing how this change is guarded by the experiment.
There was a problem hiding this comment.
Thanks! Fixed it. PTAL.
|
R: @scwhittle |
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #37574 +/- ##
============================================
- Coverage 57.23% 55.60% -1.64%
+ Complexity 5120 2095 -3025
============================================
Files 1396 1102 -294
Lines 197997 172412 -25585
Branches 4826 1349 -3477
============================================
- Hits 113326 95870 -17456
+ Misses 80835 74163 -6672
+ Partials 3836 2379 -1457
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
R: @scwhittle |
| } | ||
| @Nullable BitSet currentBits = finishedSetState.read(); | ||
| if (currentBits == null || !currentBits.equals(modifiedFinishedSet.getBitSet())) { | ||
| finishedSetState.write(modifiedFinishedSet.getBitSet()); |
There was a problem hiding this comment.
I'm not seeing how this change is guarded by the experiment.
| return; | ||
| } | ||
|
|
||
| if (!readFinishedBits(finishedSetState).equals(modifiedFinishedSet)) { |
There was a problem hiding this comment.
Note: before this PR this check always returned true due to equals method missing in FinishedTriggersBitSet. With the added equals method, won't be writing finishedSetState every time.
The optimization is not enabled by default and is behind an experiment
unstable_not_update_compatible_new_window_optimization. The optimization is enabled only for non merging windows.