Skip to content

Cache tower node bbox in EdgeIteratorState - #2338

Closed
otbutz wants to merge 6 commits into
graphhopper:masterfrom
otbutz:iter_bbox
Closed

otbutz wants to merge 6 commits into
graphhopper:masterfrom
otbutz:iter_bbox

Conversation

@otbutz

@otbutz otbutz commented Jun 2, 2021 •

Copy link
Copy Markdown
Contributor
  • allows to check for tower node bbox intersection via the EdgeIteratorState
  • caches the created BBox to speedup handling of multiple area checks
  • resets the BBox within EdgeIteratorImpl.goToNext() to avoid recreating it for every visited edge

@otbutz

otbutz commented Jun 8, 2021

Copy link
Copy Markdown
Contributor Author

@karussell the changes proposed here should be less intrusive than those in #2327

@karussell

Copy link
Copy Markdown
Member

Although we do some caching already in EdgeIteratorState (flags) I would not want this (yet). I can see the requirements but I can also see the big problems with caching. Also this change requires a separate interface (and when is the cached value reset - shouldn't it be done when setWayGeometry is called?).

The least invasive change could be probably to cache the PointList in the EdgeIteratorState somehow or store the bbox like proposed in #2320 (comment). But even if this would be possible I (currently!) do not see the need to have this cached. E.g. we currently should focus on making longer route requests much faster with simple custom models (avoid motorway, ferry, ...) instead of making routing a bit faster for specific use cases (many areas).

@otbutz

otbutz commented Jun 14, 2021 •

Copy link
Copy Markdown
Contributor Author

shouldn't it be done when setWayGeometry is called?

Good catch. Currently the reset happens here:

https://github.com/graphhopper/graphhopper/pull/2338/files#diff-267f44bcfcb3b930af5a645649c8c73fed2c7ecfc2a1998d6ce4af276f800de5R941-R943

Edit: doesn't setWayGeometry only touch pillar nodes? That shouldn't change the bbox for tower nodes

The least invasive change could be probably to cache the PointList in the EdgeIteratorState

Gave this one a little bit of thought but we need the full way geometry pretty late as the bbox check is sufficient for most examined edges.

or store the bbox like proposed in #2320 (comment).

Depends on which kind of bbox we're talking about. The bbox for the complete way geometry is a lot more taxing. The one of the tower nodes is rather cheap but we still suffer from having to create visited edges * areas BBox instances for each run.

specific use cases (many areas).

The caching is already notable for a single area as we create and modify a single BBox instead of a BBox per edge.

@otbutz

otbutz commented Sep 23, 2021

Copy link
Copy Markdown
Contributor Author

@karussell i gave it a bit of thought lately and we could skip all of the ReadableBBox stuff i've we do the intersection check within the EdgeIteratorState. e.g:

boolean intersectsTowerBBox(BBox bbox);

@otbutz

otbutz commented Sep 24, 2021

Copy link
Copy Markdown
Contributor Author

@karussell this version should be a lot less invasive and keeps the cached BBox within the iterator.

return true;
}

return shape.intersects(fetchWayGeometry(FetchMode.ALL).makeImmutable());

@otbutz otbutz Sep 24, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could also cache the way geometry here and drop it when goToNext() or setWayGeometry() is called.

@otbutz

otbutz commented Oct 5, 2021

Copy link
Copy Markdown
Contributor Author

@karussell any chance to get this merged?

@karussell

Copy link
Copy Markdown
Member

My opinion in this matter is still unchanged:

Although we do some caching already in EdgeIteratorState (flags) I would not want this (yet). I can see the requirements but I can also see the big problems with caching.

I know this is unsatisfying but I would currently not like to optimize it.

And when we optimize we really need some numbers with serious improvements (to justify the caching ugliness) and then I would probably even go further and store the pointlist bbox in the wayGeometry somehow like @easbar suggested in the other issue.

@otbutz

otbutz commented Oct 7, 2021

Copy link
Copy Markdown
Contributor Author

store the pointlist bbox in the wayGeometry somehow like @easbar suggested in the other issue

Ultimately, this is the cleanest approach.

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