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

PERF: Additional performance updates #1209

Merged
merged 2 commits into from
Dec 21, 2022
Merged

Conversation

greglucas
Copy link
Contributor

This is whittling down the last two easy to find performance bottlenecks using snakeviz. See the image below.

image

Commit 1: Removes the hash calls to enum from the dict access. It is small enough and only used in one place that we can inline it.
Commit 2: (far right purple box is ProjError.clear()) Removes the class attribute of the internal_proj_error and moves that into Cython to take care of all the error messages without needing to access Python objects while within C.

The __hash__() calls add some overhead for the relatively few number
items that we can inline instead.
@snowman2
Copy link
Member

This is great! How much does it improve the performance?

@greglucas
Copy link
Contributor Author

I go from about 1.5 us -> 1.1 us / iteration of transform_point (rebased on your branch). Maybe see the results of calling it 2,000,000 times to get the cumulative. Here are the figures below relative to the original one included above, although I'm not sure we really get that much of a speedup.

After the first commit:
image

After the second commit:
image

@snowman2
Copy link
Member

Every little speedup counts. I think that this is a worthwhile change. Thanks for working on this 👍

This moves the internal PROJ error message to Cython for faster
get/clear from the C side. The Python side can still access it, it
is just no longer stored as a class attribute. This provides a
performance benefit primarily within the Transformer functions.
@snowman2 snowman2 merged commit 6483356 into pyproj4:main Dec 21, 2022
@snowman2
Copy link
Member

Thanks @greglucas 👍

@greglucas greglucas deleted the perf-updates branch December 21, 2022 14:04
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.

2 participants