Merged
Conversation
Member
Author
|
BTW, when assuming data is correct, performance could be also improved with |
clallemand
approved these changes
Nov 21, 2024
Contributor
clallemand
left a comment
There was a problem hiding this comment.
I've tested this fix on one of our (LexImpact) simulations and it seems to works !
f7298f3 to
bc092d8
Compare
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.
Fixes #1306
Performance
43.0.0fixed impending bugs inindexed_enumsand improvedEnumArrayperformance
Enun.__eq__andEnum.encodesuffered from performancedegradation on large datasets
by the aforesaid published version
Note to reviewers
Some of the spectacular performances of
Enum.encodecame from the fact thatit didn't actually work, leaving buggy behaviour unseen (see for example
openfisca/openfisca-france@84e41a5).
This PR introduces
O(n)andO(1)use of fancy indexing, vector masking, andnumpy.searchsorted, that scales nicely with large datasets (10k+).However, as we need to validate data at enum encoding time, the encoding of
intandstrsequences can't be faster than the pre-43.0.0 just becausedata has to be copied over.
If ever this becomes problematic for very large datasets (50M+), we can workout
a feature flag to disable fancy indexing and trusting data has been properly
validated priorly by the user disabling run-time data validation, and so to
gain from the performance of using a memory view instead of copying data over
(that is, not using neither fancy indexing nor binary search).
However, it seems the least surprising for every user that the data be
validated before encoding (out of bounds indices and wrong
strvalues notpresent in an
Enum).Benchmarks
Against
42.0.0Against
43.0.0