Reduce Route Calculation Time

I’ve loaded osm data for Germany with CH disabled, Ram store and a custom weighting. I’ve a system with 16gb Ram, 4 cores and 50gb disk. The route generation is taking around 4seconds. Any suggestions on how do I optimize the time taken?

Edit: I also tried using Landmark algorithm but somehow the custom weighting fails to have its effect. I tried with 64 landmarks.

Try to profile the custom weighting and do as few work as possible in the custom weighting. A route with the fastest weighting takes on average 1.4s … but we usually recommend the hybrid mode.

Edit: I also tried using Landmark algorithm but somehow the custom weighting fails to have its effect. I tried with 64 landmarks.

It should work like described in the other topic

Im not saying that the hybrid doesnt work at all. It just gives a different result with the custom weighting whem compared to normal mode. Any suggestions related to using Landmark mode?

It just gives a different result with the custom weighting whem compared to normal mode.

It shouldn’t.

Any suggestions related to using Landmark mode?

Without any specifics (code or exceptions etc) it’s hard to help you out.

So you mean to say even if I use 16 landmarks, the result should be the same as to what I get in the normal mode with custom weighting?

If your code is correct, the hybrid and flexible mode produce the same results, hybrid is faster, but needs more ram and time to preprocess. See this blog post.

Below is the code snippet of class which extends Graphhopper. It generates landmarks_car_mycustom and also subnetworks_landmarks_car_mycustom

	private DAType dataAccessType = DAType.RAM_STORE;

    public MyGraphHopper() {
    	chFactoryDecorator.setEnabled(false);
    	lmFactoryDecorator.setEnabled(true);
    	algoDecorators.add(chFactoryDecorator);
    	algoDecorators.add(lmFactoryDecorator);
    }


    @Override
    public boolean load(String graphHopperFolder) {
	...
     	if (lmFactoryDecorator.isEnabled()) {
	    	lmFactoryDecorator.setWeightingsAsStrings(Arrays.asList("mycustom"));
	    	initLMAlgoFactoryDecorator();
	    }    	
	...
    }

You should not overload GraphHopper to enable the custom weighting for LM. Do the config via hopper.getLMFactoryDecorator before importOrLoad and see the unit tests how we do this. Also do not forget about the custom weighting that currently needs overloading the GraphHopper class: https://github.com/graphhopper/graphhopper/blob/master/docs/core/weighting.md

@karussell changed as per your suggestion, the routing is really fast now for routes which are around 100km. Once it reaches around 400km it starts super slow like 5-6s. Is this how it should be or am I missing something?

Did a clean install, cleaned up some code and restarted my server. Seems to perform better now. But can’t really say what made the improvement, sadly. Perhaps setting the -Xmx value and some GC settings…

1 Like