-
Notifications
You must be signed in to change notification settings - Fork 76
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
Improve performances #905
Improve performances #905
Conversation
@@ -8,6 +8,9 @@ | |||
|
|||
Since a period is a triple it can be used as a dictionary key. | |||
""" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to remove the type annotations if considered off-topic. I've added them on the way while working on other optimizations I since then reverted, but figured out they are valuable and don't complicate the review that much.
@@ -272,7 +272,7 @@ def ordered_members_map(self): | |||
This function only caches the map value, to see what the map is used for, see value_nth_person method. | |||
""" | |||
if self._ordered_members_map is None: | |||
return np.argsort(self.members_entity_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value was never put in cache, resulting in running this costly argsort many many times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to reset the cache to None in @members_entity_id.setter
.
@@ -158,6 +158,7 @@ def purge_cache_of_invalid_values(self): | |||
for (_name, _period) in self.invalidated_caches: | |||
holder = self.get_holder(_name) | |||
holder.delete_arrays(_period) | |||
self.invalidated_caches = set() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once all the invalidated items have been removed from the cache, we can empty the set, otherwise it will keep trying to remove them from cache over and over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fpagnoux The following test generates the graph on master
branch but I get an empty graph on this branch :
openfisca test openfisca-france/tests/formulas/irpp.yaml --performance -c openfisca_france -n "Test de la CSG déductible sur revenus du patrimoine (2017)"
Forgot (already) about the server. 🤦♀
Rebasing |
e988153
to
8ed381e
Compare
Fix minor errors that result in operations being uselessly repeated over and over.