Add option to pickler dumps() for best-effort determinism#34698
Merged
tvalentyn merged 5 commits intoapache:masterfrom Apr 25, 2025
Merged
Add option to pickler dumps() for best-effort determinism#34698tvalentyn merged 5 commits intoapache:masterfrom
tvalentyn merged 5 commits intoapache:masterfrom
Conversation
The motivation for this change is Flume caches pickled code and non-determinism breaks the caching. While making pickling fully-determinism is infeasible, increasing the determinism is still useful due to the increase in cache hits. Sets are a common source of non-determinism. This change sorts set elements to provide deterministic serialization. Because not all types provide a comparison operator, the sorting routine implements generic element comparison logic. See: apache#34410
tvalentyn
reviewed
Apr 21, 2025
Contributor
|
Assigning reviewers. If you would like to opt out of this review, comment R: @tvalentyn for label python. Available commands:
The PR bot will only process comments in the main thread (not review comments). |
tvalentyn
approved these changes
Apr 23, 2025
Contributor
|
cc: @claudevdm |
The FlumeRunner will enable this feature flag via its canary mechansim. The option is localized to only serialization of transforms because that is what the FlumeRunner wants to cache. It will not enable best-effort deterministic serialization for other uses of pickling.
Contributor
|
rerunning tests |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #34698 +/- ##
============================================
+ Coverage 54.61% 54.63% +0.02%
Complexity 1480 1480
============================================
Files 1008 1010 +2
Lines 159767 159960 +193
Branches 1079 1079
============================================
+ Hits 87262 87402 +140
- Misses 70403 70456 +53
Partials 2102 2102
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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The motivation for this change is Flume caches pickled code and non-determinism breaks the caching. While making pickling fully-determinism is infeasible, increasing the determinism is still useful due to the increase in cache hits. Sets are a common source of non-determinism. This change sorts set elements to provide deterministic serialization. Because not all types provide a comparison operator, the sorting routine implements generic element comparison logic.
See: #34410