You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
routing requests like /maps/?point=1.346528%2C103.753174&point=1.348105%2C103.747788&point_hint=&point_hint=Singapore are already much faster. Will see what else can be done.
Yeah, I was really surprised to see that this was so slow. In general the point_hint parsing is very costly. See #1718, where I tried to improve some other parts.
One of the causes for the slowness seems to be the rather expensive NON_WORD_CHAR.replaceAll.
Or even a cache for "name->prepareName" could make sense (that we could try to reuse for different edges but also for different waypoints somehow, although I would try to avoid this as caching is hard)
That is a good idea that I tried. Although it has the same speed I prefer it over the current solution due to its simplicity. The only failing test is now:
Expected :i28north
Actual :28north
at com.graphhopper.routing.util.NameSimilarityEdgeFilterTest.normalization(NameSimilarityEdgeFilterTest.java:139)
This is due to the double cleaning (once with string.split and once with matcher). I'm unsure if this is important as e.g. "B 97" is also removed to "97".
It seems to be the only test case which fails and I wouldn't have expected it to return i28north to be honest. Blindly adding the i from I- could be dangerous.
btw: compared to the old master the PR this matcher loop (and also the "complicated split PR") is a bit faster :). So the point_hint slowed down the CH requests on old master by roughly 35%. Now it is "only" 31% slower.
Why is point_hint so expensive ? Haven't looked into this, but I thought we 'only' need to look up the street names for a few edges (the ones that are close to the snapped location after the location index lookup) ?
@karussell it might be worth to write a quick JMH benchmark to track this down properly.
I used our Measurement class. It kind of pre-dates JMH but does everything on real data. Also to know the global context i.e. how heavy something is compared to something else to avoid micro tuning.
Why is point_hint so expensive ?
First, because we loop over so many edges in the neighborhood and second, because CH is extremely fast ;)
You won't be disappointed, better than Slack IMHO.
Sorry, I usually don't spam other repos with my personal opinion. And you know I love your work here. I do feel generally though that several discussions in issues/PRs in GH repo is often more an internal discussion, better suited for your forum (still public at least) or chat. Putting only the milestone comments to GH would make it more understandable for other people too, instead of having to go through 50+ comments (you gotta admit, not that uncommon). Anyways, just wanted to mention it:)
In other words: the current approach is only suitable if the names largely consist of ASCII characters as there are multiple ways to generate the same letter in UTF-8. We would need to normalize and apply ASCII-folding to the names and the search term if we want to use in regions with other scripts.
Activity
otbutz commentedon Sep 9, 2019
I suspect that creating the
NumberFormatExceptionis a rather costly operation.Ignoring any leading
-or+signs:Bonus point: it should be only evaluated for the
rewrite.length() <= 2case nowkarussell commentedon Sep 9, 2019
Yeah, I was really surprised to see that this was so slow. In general the point_hint parsing is very costly. See #1718, where I tried to improve some other parts.
One of the causes for the slowness seems to be the rather expensive NON_WORD_CHAR.replaceAll.
Or even a cache for "name->prepareName" could make sense (that we could try to reuse for different edges but also for different waypoints somehow, although I would try to avoid this as caching is hard)
otbutz commentedon Sep 9, 2019
Maybe it's better to create a
WORD_CHARmatcher for the whole name and iterate over the positive matches.otbutz commentedon Sep 9, 2019
otbutz commentedon Sep 9, 2019
If we'd like to ignore cases of alphanumerical characters intermixed with removeable ones:
Pattern.compile("(?<=^|\\s)\\p{LD}+(?=\\s|$)")karussell commentedon Sep 9, 2019
That is a good idea that I tried. Although it has the same speed I prefer it over the current solution due to its simplicity. The only failing test is now:
This is due to the double cleaning (once with string.split and once with matcher). I'm unsure if this is important as e.g. "B 97" is also removed to "97".
otbutz commentedon Sep 9, 2019
It seems to be the only test case which fails and I wouldn't have expected it to return
i28northto be honest. Blindly adding theifromI-could be dangerous.karussell commentedon Sep 9, 2019
Ok
btw: compared to the old master the PR this matcher loop (and also the "complicated split PR") is a bit faster :). So the point_hint slowed down the CH requests on old master by roughly 35%. Now it is "only" 31% slower.
easbar commentedon Sep 9, 2019
Why is point_hint so expensive ? Haven't looked into this, but I thought we 'only' need to look up the street names for a few edges (the ones that are close to the snapped location after the location index lookup) ?
otbutz commentedon Sep 9, 2019
@karussell it might be worth to write a quick JMH benchmark to track this down properly.
karussell commentedon Sep 9, 2019
I used our Measurement class. It kind of pre-dates JMH but does everything on real data. Also to know the global context i.e. how heavy something is compared to something else to avoid micro tuning.
First, because we loop over so many edges in the neighborhood and second, because CH is extremely fast ;)
otbutz commentedon Sep 9, 2019
Could you profile the execution with jvisualvm? Would be nice to see where we're loosing performance exactly.
otbutz commentedon Sep 9, 2019
Sidenote: we seem to support Unicode Strings here but use the regular String similarity metrics without any Unicode normalization
nilsnolde commentedon Sep 9, 2019
Can I sponsor you a Rocket.Chat server for chats? ;)
karussell commentedon Sep 9, 2019
A simple LinkedHashMap (LRU) reduces this now to only +20%
Sure. JaroWinkler.similarity is one and the other is still prepareName
What do you mean here?
@otbutz let us go to https://discuss.graphhopper.com/t/improve-speed-of-point-hint/4728(btw: I really dislike that github sends one email per issue entry. Does not make sense if there are multiple per minute)
easbar commentedon Sep 9, 2019
its easy enough to unsubscribe an issue when it becomes too noisy / is not of your interest ?
but at least I got to know rocket chat now :)
nilsnolde commentedon Sep 9, 2019
You won't be disappointed, better than Slack IMHO.
Sorry, I usually don't spam other repos with my personal opinion. And you know I love your work here. I do feel generally though that several discussions in issues/PRs in GH repo is often more an internal discussion, better suited for your forum (still public at least) or chat. Putting only the milestone comments to GH would make it more understandable for other people too, instead of having to go through 50+ comments (you gotta admit, not that uncommon). Anyways, just wanted to mention it:)
otbutz commentedon Sep 9, 2019
Wouldn't this imply that there are a lot of entities sharing the exact same name?
https://withblue.ink/2019/03/11/why-you-need-to-normalize-unicode-strings.html
https://www.w3.org/TR/charmod-norm/#matchingAlgorithm
In other words: the current approach is only suitable if the names largely consist of ASCII characters as there are multiple ways to generate the same letter in UTF-8. We would need to normalize and apply ASCII-folding to the names and the search term if we want to use in regions with other scripts.