Skip to content

PRF: Speed up point_in_path and friends #6450

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

Merged
merged 4 commits into from
May 19, 2016
Merged

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented May 19, 2016

This is an alternative to #6446. Fix #6444.

  • Moves to using (, ) instead of [] for indexing in point_in_path_impl which avoids Python ref/deref and is therefore much faster
  • Renames operator[] to subarray (which is still useful in some places where speed is less critical) and moves to using (, ,) elsewhere in the codebase where it makes sense.
  • Reverts the use of bool for the results in point_in_path_impl, which strangely was a lot slower
  • Doesn't use the contouring algorithm unless the radius is nonzero. This is a large performance win and brings us under 1.4.3 times in the common case.

mdboom added 4 commits May 19, 2016 08:15
Since we now know the performance is so bad, this should discourage its
use and flag it as something special.

Also, use () in more places
@mdboom mdboom added this to the 1.5.2 (Critical bug fix release) milestone May 19, 2016
@mdboom
Copy link
Member Author

mdboom commented May 19, 2016

Thanks to @tacaswell and @QuLogic for the legwork on this one!

@tacaswell tacaswell mentioned this pull request May 19, 2016
subtrans(1, 1),
subtrans(0, 2),
subtrans(1, 2));
int it = i % Ntransforms;
Copy link
Member

Choose a reason for hiding this comment

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

here you are using int's, but elsewhere, you use size_t. Any particular reason for that?

@WeatherGod
Copy link
Member

I am also perplexed about the performance issues with bool vs. uint8_t. Perhaps we should mention it to the numpy folks to see if they have any insights? That is the only change that has me a bit uneasy. Other than that, this looks good to me.

@tacaswell
Copy link
Member

If I recall correctly stl special cases bool and implements it as a
bitfield on top of a vector of ints. I bet the translation layer in there
where the extra cost is.

As this is stl I do not think numpy would have any input (as I thought they
were all c).

Tom

On Thu, May 19, 2016 at 9:30 AM Benjamin Root notifications@github.com
wrote:

I am also perplexed about the performance issues with bool vs. uint8_t.
Perhaps we should mention it to the numpy folks to see if they have any
insights? That is the only change that has me a bit uneasy. Other than
that, this looks good to me.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#6450 (comment)

@dopplershift
Copy link
Contributor

dopplershift commented May 19, 2016

@tacaswell I remembered something similar to you about std::vector<bool>, and we're correct: http://en.cppreference.com/w/cpp/container/vector_bool

Notes from there:

  1. vector<bool> is not necessarily contiguous in memory (WTF???)
  2. vector<bool> packs bits together.

So, going back to vector<uint_8> should be much better.

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.

4 participants