Skip to content

feat: Add option to control deserialization when watching events #2406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kevinz857
Copy link

@Kevinz857 Kevinz857 commented May 31, 2025

What type of PR is this?

/kind feature
/kind optimization

What this PR does / why we need it

This PR adds an option to disable automatic deserialization in the Watch.stream() method. When watching large volumes of resource updates, the default deserialization of every event can cause significant latency overhead and potential processing delays.

By allowing clients to opt-out of automatic deserialization when only basic JSON parsing is needed, we can significantly reduce time cost and improve event processing throughput. This is particularly important in scenarios with high event volumes or resource constraints, where the overhead of deserializing every object into full model instances becomes a bottleneck.

Key changes

  • Added a deserialize parameter to Watch.stream() method (defaults to True for backward compatibility)
  • When deserialize=False, events are only JSON parsed without model conversion
  • Maintains the original behavior when deserialize=True
  • Added test cases to verify both behaviors

Special notes for your reviewer

This change is backward compatible with existing code as it defaults to the current behavior (deserialize=True). Users can specifically opt-in to the performance optimization by setting deserialize=False when needed.

Does this PR introduce a user-facing change?

Add option to disable automatic deserialization in the Watch.stream() method to improve performance in high-volume watching scenarios

… is required

This PR adds an option to disable automatic deserialization in the Watch stream().
By allowing clients to opt-out of automatic deserialization when only basic
JSON parsing is needed, we can significantly reduce time cost and improve
event processing throughput. This is particularly important in scenarios with
high event volumes or resource constraints.

Key changes:
- Added a 'deserialize' parameter to Watch.stream() method (defaults to True for backward compatibility)
- When deserialize=False, events are only JSON parsed without model conversion
- Maintains the original behavior when deserialize=True
- Added test cases to verify both behaviors
@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels May 31, 2025
@k8s-ci-robot
Copy link
Contributor

@Kevinz857: The label(s) kind/optimization cannot be applied, because the repository doesn't have them.

In response to this:

What type of PR is this?

/kind feature
/kind optimization

What this PR does / why we need it

This PR adds an option to disable automatic deserialization in the Watch.stream() method. When watching large volumes of resource updates, the default deserialization of every event can cause significant latency overhead and potential processing delays.

By allowing clients to opt-out of automatic deserialization when only basic JSON parsing is needed, we can significantly reduce time cost and improve event processing throughput. This is particularly important in scenarios with high event volumes or resource constraints, where the overhead of deserializing every object into full model instances becomes a bottleneck.

Key changes

  • Added a deserialize parameter to Watch.stream() method (defaults to True for backward compatibility)
  • When deserialize=False, events are only JSON parsed without model conversion
  • Maintains the original behavior when deserialize=True
  • Added test cases to verify both behaviors

Special notes for your reviewer

This change is backward compatible with existing code as it defaults to the current behavior (deserialize=True). Users can specifically opt-in to the performance optimization by setting deserialize=False when needed.

Does this PR introduce a user-facing change?

Add option to disable automatic deserialization in the Watch.stream() method to improve performance in high-volume watching scenarios

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Kevinz857
Once this PR has been reviewed and has the lgtm label, please assign yliaog for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested review from fabianvf and yliaog May 31, 2025 10:35
@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 31, 2025
@roycaihw
Copy link
Member

roycaihw commented Jun 4, 2025

/assign

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants