-
-
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
[WIP] AVL tree + performance tweaking #42
Conversation
w8r
commented
Sep 8, 2017
- proceeding with work on adopting faster tree data structure
- Took in @rowanwins changes for union construction
- split the code for convenience
- trying to tweak the performance
Hi @w8r I've been doing some scratching through this martinez implementation to see if it can provide anything useful I wondered if this chunk in particular might help in the subdivide_segments function for unions given that we're experiencing slowness particuarly with our union operation... My initial implementation of it is failing, I simply added the following but I think Im incorrectly interpreting the
Will see if I come across anything else useful |
Looking at this implementation it looks as though the creation of the polygon is done as new vertices are added, rather than at the end (which our |
Also note there are some c++ files in here which you might find easier to read. |
And another potential source for inspiration using php. This one looks relatively new and well organised. |
Hi @w8r Well I've made a very simple change but it looks like a made a big difference and |
Oh this is amazing, you cut off so much unnecessary loops! I totally didn't see that opportunity |
interestingly the benchmark test doesn't appear to make as much difference as the browser, I wonder why that is... |
It looks like the next hurdle might be something in the subdivide_segments |
@@ -4,7 +4,14 @@ | |||
// var abs = Math.abs; | |||
|
|||
module.exports = function equals(p1, p2) { |
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.
But this one I have mostly kicked out trying to minimize function calls. However it didn't give much gain
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.
Simple operations like this won't have much performance gains in the grand scheme of things.
However, dropping for loops
helps a lot!
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.
yeah this was a bit of a long shot but I figured if it was a micro-optimisation that was being called a squillion times it might help, see https://jsperf.com/andcomparitor/1 (although the results are depenedent on what browser you use)
Now I see some problem in |
👏 😄 |
@w8r we could really use these changes... any idea when you think they'll be ready to merge? |
Hi @gap777 Unfortunantly it's still a little while away. Hopefully once I get the new Turf.js docs released in the next week I'll be able to do some digging into the remaining bugs. |
Hi @w8r I'm starting to look at this again, I'm determined to crack it one day! You'll see I've added a new style of test which is designed to check each of the potential input geometries (polys, poly with hole, multipoly) against each of the operations. These test use super-simple geometries to try and debug and are clearly named so hopefully they will help us track down what is happening. |
This is amazing, feel free to poke me, I am supposed to have more free time this week |
Will try and get the suite roughly ready and then will report back on those which are throwing issues. |
Ah thanks for that. Looking at it the result of that holecut difference looks incorrect, while the visual result shown on the map looks ok the actual result array is incorrectly nested, I'll do a quick dig now and see if I can work out why... |
yes, nesting is the problem there |
Think I've got it sussed, just running some more checks, stay tuned |
Well that was good, I removed some lines that had always concerned me regarding the operation type. And I was also able to remove that final loop as well. |
Bah sorry confused myself when I was checking others. I know why it's not working, its because it's marked as an interior ring. But if it's an exterior ring on a difference operation, but the subject box is within the clipping bbox, then it should be treated as a hole. I haven't worked out how to best test for it though and rectify it. |
Have pushed a fix for that difference hourglass nesting bug , not sure how solid it is but the tests pass. |
I guess everything is ok |
I'll squash if you don't mind, don't see how the separate commits would help reconstructing this drama |
#35 is still completely broken, but ok, it will be the next one https://codepen.io/w8r/pen/XVKNQw?editors=0010 |
and #12 will be broken after the merge |
@w8r and @rowanwins - it sounded like you guys were headed towards a release soon. What's your intention in the near future? |
thank you @rowanwins ! |
released as v0.3.0. I saw a couple of small problems with a tree and also how to improve the demo and releasing, that will go to the patches |
That was epic @w8r !!! |
👏 👏 nice! |