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

Valhalla routing causes memory issues on Jolla 1 #153

Closed
a-dekker opened this issue Jun 16, 2017 · 10 comments
Closed

Valhalla routing causes memory issues on Jolla 1 #153

a-dekker opened this issue Jun 16, 2017 · 10 comments

Comments

@a-dekker
Copy link

I have been trying the new Valhalla routing on my Jolla One, but found it unusable.
Harbour-osmscout-server-module-route and harbour-osmscout-server use too much memory, so harbour-osmscout-server get's killed during route searches, leaving harbour-osmscout-server-module-route as an orphan. I am using Poor Maps, and the routes are not that complex.
Disabling Valhalla causes no memory issues (the harbour-osmscout-server-module-route process is not present, making a big difference).

@rinigus
Copy link
Owner

rinigus commented Jun 16, 2017

That's a bummer! What I can see from the stats that I collected over the development, the code size has increased from ~60MB to 140MB (peaking 200MB sometimes) and the RSS staying relatively constant, maybe even smaller now than in January (450MB for me now).

But let's try to reduce memory consumption as much as we can.

I presume you are using Mapnik/Geocoder-NLP/Valhalla. It all starts up and the problem appears only while route search, right?

To reduce RAM to minimum:

  • In Settings/Geocoder-NLP settings: ensure that you have selected languages in search. Then, on the bottom of it, select "Load libpostal on every call"

  • In Settings/Valhalla settings: reduce cache to 16MB

If this will not help, let's try:

  • In Poor Maps, select Mapbox as basemap (so we don't have to render images while calculating route)

  • In Poor Maps, enter the destination not by address, but by selecting it and choosing Navigate in pop-up.

Please let me know how it went. I sincerely hope we could fit it into J1

@a-dekker
Copy link
Author

a-dekker commented Jun 16, 2017

I changed the default settings according to your advice, and that did certainly help. Especially the memory usage of harbour-osmscout-server-module-route dropped. Re enabling "Load libpostal on every call" does not seem to make a big difference, so the cache of Valhalla seems to be the culprit. Routing using a value of 64MB also went fine (about up to 20% mem for harbour-osmscout-server-module-route).
No idea what the limit should be, that will also depend on the amount of other active apps. But perhaps the default memory values should be a bit more conservative for the Jolla 1.

edit: using 32 MB now, still had some crashes with 64MB every now and then.

@rinigus
Copy link
Owner

rinigus commented Jun 17, 2017

I tested it with 16MB and it all seemed to be fine when calculating routes in Sweden. I think that I set 16MB as a minimum in GUI. Try to test whether the speed is fine with 16MB or whether you see better performance with 32MB. Then we can set the cache default to the corresponding value.

@a-dekker
Copy link
Author

It's hard to seen any difference between using 32 or 16 MB. But it is certainly faster than libosmscout :-)
And maybe a warning included in the setting that you should lower the value in case you experience OOM kills. Setting a default value dependent on the amount of RAM would perhaps go too far.

@rinigus
Copy link
Owner

rinigus commented Jun 17, 2017

Great! The most important is that it works for you know on J1! So, all we have to do is to make sensible default and warn current users of OOM kill danger.

I'll see how to check for RAM amounts and maybe its rather simple to setup 16MB as a default for 1GB RAM variants and bit more for the larger ones (64MB for 2GB and 128 for 3GB and up, for example).

Let's keep issue alive until the defaults are changed.

@a-dekker
Copy link
Author

a-dekker commented Jun 18, 2017

And an additional remark: routes by bike of foot are more complex. It kept on crashing while a was looking for a route on bike (16 MB memory allocated), but it searched for a town 188 km away instead of 50 km away. More realistic distances by bike or foot just work.
It still makes me wonder: does it take more memory if it really needs to (as I got OOM kills with 16MB)?

@rinigus
Copy link
Owner

rinigus commented Jun 18, 2017

Well, all we specify is tile cache. Other internal Valhalla structures do take additional memory and I don't know any mechanisms to regulate that. However, it should be possible to limit maximal radius for the route search. Would have to look into it.

@a-dekker
Copy link
Author

Sound logical.
Lesson learned for me: if I had searched the location in Poor Maps first (so I knew the destination was correct) and then had asked for the route it would not have been an issue.

@rinigus
Copy link
Owner

rinigus commented Jun 18, 2017

:) good tip!

@rinigus
Copy link
Owner

rinigus commented Jun 20, 2017

In the development version, its possible to set Valhalla's routing limits to avoid too complicated routes. Defaults are relatively conservative, so it should limit the crashes. For this to work, the next version of the router would be needed as well. In practice, I would have to release either the server and the router simultaneously, or router after the server (otherwise it would break).

Closing the issue since the problems should be resolved now.

@rinigus rinigus closed this as completed Jun 20, 2017
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

No branches or pull requests

2 participants