Skip to content

[Dataflow Streaming] [Multi Key] Introduce KeyGroupWorkQueue and integrate with BoundedQueueExecutor#38767

Open
arunpandianp wants to merge 1 commit into
apache:masterfrom
arunpandianp:multikey_compqueue
Open

[Dataflow Streaming] [Multi Key] Introduce KeyGroupWorkQueue and integrate with BoundedQueueExecutor#38767
arunpandianp wants to merge 1 commit into
apache:masterfrom
arunpandianp:multikey_compqueue

Conversation

@arunpandianp
Copy link
Copy Markdown
Contributor

- Add Uint128Proto and key_group to WorkItem in windmill.proto.
- Update Work model to support key groups.
- Implement KeyGroupWorkQueue for grouping tasks by key group. KepGroupWorkQueue is a FIFO queue that allows polling elements based on global order and also by order within a key group.
- Integrate BoundedQueueExecutor with KepGroupWorkQueue and support targeted polling.

The changes are behind an experiment unstable_enable_multi_key_bundle and does not affect the default core logic.

…oundedQueueExecutor

    - Add Uint128Proto and key_group to WorkItem in windmill.proto.
    - Update Work model to support key groups.
    - Implement KeyGroupWorkQueue for grouping tasks by key group. KepGroupWorkQueue
      is a FIFO queue that allows polling elements based on
      global order and also by order within a key group.
    - Integrate BoundedQueueExecutor with KepGroupWorkQueue and support targeted polling.
@arunpandianp
Copy link
Copy Markdown
Contributor Author

R: @scwhittle

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 a new KeyGroupWorkQueue implementation to support grouping and targeted polling of work items by key group. It updates the Work model and windmill.proto to include key group information and integrates this new queue mechanism into the BoundedQueueExecutor. These changes are gated behind an experimental flag, ensuring no impact on existing core logic.

Highlights

  • Protocol Buffers Update: Added Uint128Proto and key_group field to WorkItem in windmill.proto.
  • Work Model Enhancement: Updated the Work model to support and store key group information.
  • New Queue Implementation: Introduced KeyGroupWorkQueue, a thread-safe BlockingQueue that supports both global FIFO ordering and targeted polling by computation and key group.
  • Executor Integration: Integrated KeyGroupWorkQueue into BoundedQueueExecutor, gated behind the unstable_enable_multi_key_bundle experiment.
New Features

🧠 You can now enable Memory (public preview) 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.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the 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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. 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.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for multi-key bundles in the Streaming Dataflow Worker, guarded by the unstable_enable_multi_key_bundle experiment. It adds a custom, thread-safe KeyGroupWorkQueue to allow polling work by computation and key group in FIFO order, along with corresponding updates to BoundedQueueExecutor, Work, and windmill.proto. Feedback on the new queue implementation suggests adding a defensive check in unlinkNode to prevent double-unlinking issues, and reassigning the result of checkStateNotNull in take() to satisfy static analysis nullness checks.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +126 to +135
private void unlinkNode(Node node) {
// 1. Unlink from global list
Node prevG = node.prevNode;
Node nextG = node.nextNode;
if (prevG != null && nextG != null) {
prevG.nextNode = nextG;
nextG.prevNode = prevG;
}
node.prevNode = null;
node.nextNode = null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To prevent potential issues with double-unlinking (e.g., if unlinkNode is called multiple times on the same node due to future refactoring or concurrent edge cases), we should add a defensive check at the beginning of the method. If both prevNode and nextNode are null, the node is already unlinked, and we can return early to avoid corrupting the queue's size and internal state.

  private void unlinkNode(Node node) {
    if (node.prevNode == null && node.nextNode == null) {
      return;
    }
    // 1. Unlink from global list
    Node prevG = node.prevNode;
    Node nextG = node.nextNode;
    if (prevG != null && nextG != null) {
      prevG.nextNode = nextG;
      nextG.prevNode = prevG;
    }
    node.prevNode = null;
    node.nextNode = null;

Comment on lines +254 to +258
@Nullable Node node = removeFirstGlobal();
checkStateNotNull(node, "Queue is empty but size was " + size);
Runnable task = node.task;
checkStateNotNull(task, "Encountered null task in queue");
return task;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In environments with strict nullness checking (such as the Checker Framework used in Beam), calling checkStateNotNull without reassigning the result to a non-nullable variable can still trigger static analysis warnings when dereferencing the original @Nullable reference. Reassigning the non-null result of checkStateNotNull to a non-nullable variable is the standard and safe way to satisfy the compiler and static analysis tools.

Suggested change
@Nullable Node node = removeFirstGlobal();
checkStateNotNull(node, "Queue is empty but size was " + size);
Runnable task = node.task;
checkStateNotNull(task, "Encountered null task in queue");
return task;
Node node = checkStateNotNull(removeFirstGlobal(), "Queue is empty but size was " + size);
Runnable task = checkStateNotNull(node.task, "Encountered null task in queue");
return task;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant