Skip to content
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

Merged
merged 4 commits into from
Sep 4, 2019
Merged

Improve performances #905

merged 4 commits into from
Sep 4, 2019

Conversation

fpagnoux
Copy link
Member

Fix minor errors that result in operations being uselessly repeated over and over.

@@ -8,6 +8,9 @@

Since a period is a triple it can be used as a dictionary key.
"""

Copy link
Member Author

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)
Copy link
Member Author

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

Copy link
Contributor

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()
Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@fpagnoux fpagnoux requested review from Morendil and sandcha August 27, 2019 20:46
Copy link
Collaborator

@sandcha sandcha left a 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. 🤦‍♀

@sandcha
Copy link
Collaborator

sandcha commented Sep 4, 2019

Rebasing

@sandcha sandcha merged commit 2fd3a2c into master Sep 4, 2019
@sandcha sandcha deleted the improve-perf-ipp branch September 4, 2019 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants