-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
base: master
Are you sure you want to change the base?
feat: Add option to control deserialization when watching events #2406
Conversation
… 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
@Kevinz857: The label(s) In response to this:
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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Kevinz857 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 |
/assign |
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
deserialize
parameter toWatch.stream()
method (defaults toTrue
for backward compatibility)deserialize=False
, events are only JSON parsed without model conversiondeserialize=True
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 settingdeserialize=False
when needed.Does this PR introduce a user-facing change?