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

Make plots.py significantly (4x) faster #481

Merged
merged 1 commit into from
Jul 31, 2018
Merged

Make plots.py significantly (4x) faster #481

merged 1 commit into from
Jul 31, 2018

Conversation

andylolz
Copy link
Contributor

@andylolz andylolz commented Jun 5, 2018

plots.py grinds to a near halt when it gets to this bit:

-> publisher_types
-> activities_per_publisher_type

This PR massively speeds up those two steps, by avoiding loading and parsing the same file(s) hundreds of times.

@andylolz
Copy link
Contributor Author

andylolz commented Jun 6, 2018

Without this fix, python plots.py takes 1:22:25 (user + sys) to complete on my machine.
With this fix, python plots.py takes 0:21:55 (user + sys) to complete on my machine.

@andylolz
Copy link
Contributor Author

andylolz commented Jun 14, 2018

Worth noting that this bug was introduced in 24a381e. That change looks innocuous if you assume that data.ckan_publishers is a normal dict. If that were the case, then sure, there’s a lookup inside a loop that could be outside the loop, but lookups are fast so who cares.

But data.ckan_publishers isn’t a normal dict – data.ckan_publishers[publisher] loads a JSON file from disk, and (if the publisher has changed registry ID) potentially loads a bunch of other stuff too.

So this PR just reverts that bit of 24a381e.

@andylolz andylolz changed the title Make plots.py significantly faster Make plots.py significantly (4x) faster Jun 25, 2018
Copy link
Contributor

@Ocre42 Ocre42 left a comment

Choose a reason for hiding this comment

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

Thanks for the input

@Ocre42 Ocre42 merged commit 1f50a4f into IATI:master Jul 31, 2018
@andylolz andylolz deleted the plots-speedup branch July 31, 2018 14:55
@andylolz
Copy link
Contributor Author

Cool! Thanks for merging, @Ocre42!

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.

None yet

2 participants