valhalla icon indicating copy to clipboard operation
valhalla copied to clipboard

EdgeStatus Update on edge not previously set

Open DmitryShipilov opened this issue 3 years ago • 9 comments

Hi! I have this exception, when building really long route. Why it is throwing? Why it is updated without set? Please, help me

https://github.com/valhalla/valhalla/blob/6cc2a6eaa8a66bc517b6d8a0179fc6f19865b333/valhalla/thor/edgestatus.h#L127

DmitryShipilov avatar Aug 05 '22 08:08 DmitryShipilov

do you have a request URL that demonstrates this?

dnesbitt61 avatar Aug 09 '22 12:08 dnesbitt61

I used this request

curl -X POST -H "Content-type: application/json" -H "Accept: application/json" -d '{"locations":[{"lat": -33.919785,"lon":18.425596},{"lat": 59.565155,"lon": 150.808586}],"costing":"pedestrian"}' "http://localhost:8000/route"

DmitryShipilov avatar Aug 09 '22 13:08 DmitryShipilov

that far exceeds the maximum length of a pedestrian route

dnesbitt61 avatar Aug 09 '22 14:08 dnesbitt61

is this a reason of exception? why not bad_alloc or same?

DmitryShipilov avatar Aug 09 '22 14:08 DmitryShipilov

you must have changed the config file to allow a pedestrian route that long. I am just saying that Valhalla was not designed to optimize pedestrian routes and such a long route will take a very long time and is likely to exhaust system memory. That is what happens on my computer when I raise the pedestrian.max_distance. The request runs for a couple minutes and then the server is killed due to lack of memory.

dnesbitt61 avatar Aug 09 '22 14:08 dnesbitt61

could you explain this behavior with code? I can not find lines which represent that should call oom killer. I Would appreciate

DmitryShipilov avatar Aug 11 '22 11:08 DmitryShipilov

oom is not "called", it's a kernel protection. your machine might just be very mighty and valhalla is actually not killed by oom on this amazingly long route and instead throws. what exactly goes wrong in the code is hardly of interest IMHO, unless it's reproducible on more realistic scales.

if you really really need to route pedestrians (!) from south africa to the easternmost edge of russia, you could try osrm.

nilsnolde avatar Aug 11 '22 12:08 nilsnolde

I don't know the Linux internals, but there is no Valhalla code monitoring memory and killing the process. I reran your example this morning and it worked on my laptop (32GB RAM). 20636km (12,800 miles) route length. This took about 90 seconds to compute. I added log statements to track the size of the BDEdgeLabel vectors - the forward edge labels alone are 130,000,000 labels * 64 bytes per label ~= 8GB. That is in addition to the memory used to map all the data, the EdgeStatus (map of allocated vectors), adjacency list, etc.

dnesbitt61 avatar Aug 11 '22 12:08 dnesbitt61

so in summary it seems that @DmitryShipilov doesnt have enough ram to run a route of that size. an std container tries to do an allocation and fails (because not enough memory to double the size of whatever container) and that throws this exception?

hmm no looking at the location in the code reported seems more like a bug scenario to me? its saying you are asking for me to update a label for a tile that hasnt yet been added to the edge status map. im not sure how memory pressure could make this happen. so to reproduce we'll need the exact data that was used to trigger it

@DmitryShipilov can you at least give us a stack trace and maybe tell us where you got the osm data?

kevinkreiser avatar Aug 11 '22 13:08 kevinkreiser