Repository navigation
Conversation
| // only relevant if MMAP is used | ||
| mmapLoadConfig = new MMapLoadConfig( |
There was a problem hiding this comment.
Since this is only relevant for mmap shall we include 'mmap' in the config parameter names?
So maybe it would be better to simply run a few queries instead? |
We could query with some random requests but they might fail due to connection not found or point not found. Or we implement a special endpoint that has access to the graph directly. And so I think preloading the entire base graph can be a simple step to reduce the delay at startup . Also it can be seen as a step to further reduce the initial delay. (To reduce this further we could sort the DataAccess for all CHs and if we specify load=20%, then 20% of the especially important edges will be loaded.) |
But what is the problem with failing requests? You could just keep sending random requests until a certain amount was successful. And usually you should know what data was imported and so it shouldn't be hard to send requests that work? Or is it crucial to use requests that actually load a large part of the graph? For JIT warmup this probably does not matter?
But then we still need this new API internally (and even expose it via http)
Ok, but pre-loading the base graph takes time as well according to your table?
The CH edges are already sorted by the level of the lower-level nodes. |
Yes, I think this would be required to have the same effect like mmap.load but have not tried it.
Yes, that is the reason I would combine them: load the base graph into memory (to avoid loading geometry, names, nodes while the first queries in a certain area) and use a few requests to warm up the JIT in general. E.g. think about a large graphhopper instance like worldwide with fresh data included in a load balanced setup and you do not know which areas are used but you do not have enough memory to use RAM_STORE but still want a best effort to reduce the maximum response time.
Ah, really nice, then the most likely used edges would be already loaded into physical memory :) (?)
Sorry, what I meant with "initial delay" is the slowdown of the first requests if no mmap.load is used. And this slowdown is significantly reduced. |
This depends on the query. Typical CH queries use only a few dozens or maybe hundreds of shortcuts (out of hundreds of millions for planet), some of which are on lower levels and some of which are on higher levels. It might be even more useful to just load some random segments (just guessing here). |
|
I created a more generic solution: https://github.com/graphhopper/graphhopper/compare/mmap_config The configuration is a bit more verbose but now you can change the type and preload percentage for every single DataAccess: graphhopper:
graph.dataaccess.shortcuts_mycar: MMAP;30
graph.dataaccess.nodes_ch_mycar: MMAP;30
graph.dataaccess.shortcuts_car_rarely_used: MMAP;0
graph.dataaccess.nodes_ch_car_rarely_used: MMAP;0
# the default type:
graph.dataaccess: RAM_STORE
# so all other DataAccess objects like nodes, edges, geometry, location_index, string_index_keys, string_index_vals of the base graph get this default typeWith this I got:
So it seems that MMAP preloading results in faster startup times. Then I compared the query times in cache-cold areas for MMAP 0% vs. the best MMAP config (base 100% preload + CH 30% preload). The method I used was: I picked warmup queries in Europa, Africa, Asia and North America and then queried (1) in South America and orthogonal (2) in SA.
Note, the numbers are interestingly always reproducible. Clearing the memory was required after a restart (as above). The response time of (1) after 10x (1) was always 0.12 seconds. So the "warming" with random example queries seems to improve neighboring areas a bit but likely thousands of random requests would be required for the world wide setup to reduce the initial slowdown in a broad area like MMAP preloading does. |
Ok, a thousand (CH?) queries does not sound so bad, but I can imagine that it is hard to cover a sufficient amount of the graph storage by running random queries. So let's use the extended configuration options in your new branch? |
Yes
Ok, will create a new PR |
Fixes #2416.
These new MMAP config options shall help to get cold query times similar to the case when the RAM option is used. They however do not help to warm up the JVM (JIT compiler). I.e. the first query will be still much slower than follow up queries but the difference should be reduced.
I tested this configuration on a rather slow Intel Xeon E5-1650V3 but with 256GB physical memory and an SSD disk.
Using a configuration with several edge-based CH custom profiles (no LM) leading to a graph of 247GB including a 39GB base graph plus 2.6GB location index and 8 CH profiles.
For java I used
-Xmx140g -Xms140s(and ZGC) and the MMAP config option for GraphHopper.Not really scientific measurements as I only repeated some numbers twice but as the values were very reproducible this should be fine (I ran
sudo sysctl vm.drop_caches=3after I stopped the JVM after every measurement to avoid cache effects).The query was a 3000km route against car with avoid motorway and only the first response time was used. (The response time of the second query was then always below 0.35s.)
graph.dataaccess.base.load: 100graph.dataaccess.index.load: 100graph.dataaccess.ch.load: 100The results are interesting. Especially when we try to load everything. This seems to have minimal or even no effect on the route response time although the startup time can suffer a lot. Which very likely that the required data for the route is already removed from physical memory before we can use it as the memory pressure is high when mostly everything is loaded (keep in mind the available off-heap memory is smaller than 116g=256g-140g).