feat: Add option to control deserialization when watching events
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
deserializeparameter toWatch.stream()method (defaults toTruefor 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
@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
deserializeparameter toWatch.stream()method (defaults toTruefor 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 settingdeserialize=Falsewhen 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.
/assign
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: Kevinz857, roycaihw
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~kubernetes/base/OWNERS~~ [roycaihw]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment