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

Speed up creation of vector tiles features #75874

Merged
merged 5 commits into from
Aug 4, 2021

Conversation

iverase
Copy link
Contributor

@iverase iverase commented Jul 30, 2021

While investigating an issue with a stackoverflowerror (#75543) I come to the conclusion that the problem is that we are calling the algorithm to simplify the polygon (TopologyPreservingSimplifier.simplify) to the original polygon on the pixel space. This might result in having lots of points and not too many different values and the algorithm was failing.

Therefore I thought that calling the algorithm on the original shape when defined in Spherical mercator projections might help and indeed it helped. There are no more stackoverflowerror and it has speed up quite a bit the generation of features. In my tests, a call to the API that was taking 110 seconds takes now 35 seconds!

One caveat is that the simplification might produce invalid polygons and that was causing me to hit some ClassNotFoundExceptions(see #75869) so I added a check to reject invalid polygons. Note this seems only to happen when polygon is comparable to the pixel scale but big enough not to be rejected so I think it is fine to just skip it.

There is a second improvement. In my testing I have a few big and very complex polygons so whenever I was zoom-in into them I could see the heap usage going up and eventually I got an OOM. I thought it would be easy to check if the polygon contains the tile and in this case we can just return the tile geometry. I did that and indeed the issue is gone.

@iverase iverase added >non-issue :Analytics/Geo Indexing, search aggregations of geo points and shapes v8.0.0 v7.15.0 labels Jul 30, 2021
@iverase iverase requested a review from imotov July 30, 2021 11:22
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jul 30, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

Copy link
Contributor

@imotov imotov left a comment

Choose a reason for hiding this comment

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

LGTM

@iverase iverase merged commit bba0f6c into elastic:master Aug 4, 2021
iverase added a commit that referenced this pull request Aug 4, 2021
Simplify the shape when defined in spherical mercator projection instead of when defined in pixel space.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v7.15.0 v8.0.0-alpha2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants