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
Geometry is limited by 2^31 (after a change here it is now limited by 2^32-1).
As the geometry ref is a positive integer only and we point into the DataAccess object with this int (without any conversion) there is a limit of 2^31 ints encoded from a list of "lat,lon,ele" which could be reachable for the world wide case when all ways are included. (2^31 because of signed int vs. 2^32 unsigned for other programming languages)
For car,bike2,foot it is currently only geo:1 676 518 308(6396MB) (and edges:178 094 237(6115MB))
We increased the limit to (2^32-1) which makes this issue a lot less critical, this could only be tested via some unit test and this real world test. Will still let it open.
From what I see in BaseGraph, it uses DataAccess (a kind of abstract byte storage) to save bytes. PointList gets encoded into a list of lat, lon and possibly ele, 4 bytes each which are then saved in wayGeometry altogether as a byte array.
I'm not quite sure where the limit is. Is it the type of geoRef? I see this:
long geoRef = Helper.toUnsignedLong(edges.getInt(edgePointer + E_GEO));
Is the problem that geoRef is stored as unsigned int? Why can't we store it as long instead? Probably because it will add 4 bytes per edge and that would be too much of memory? How many edges do we have? If it's only 178 094 237 (not sure about the number above), 4 extra bytes per edge will be around 700 MB, that does not seem too much.
We can add just one or two bytes if it's critical, that would increase the capacity to 2^40/2^48 which will be more than enough - without significantly increasing the size of the edge storage. Or am I missing something?
Or is there a limit of DataAccess size like 4GB file size or something?
To reduce severity of this issue one can additionally reduce the storage usage by:
This actually does not increase the possible space of geoRef but reduces the rate of geoRef growth, right? The size of the byte array of the point list will be smaller so geoRef will grow slower.
I think we can win 1 bit if we don't save len * dim but just len. dim is 2 or 3 so this would give at least 1 bit.
Concerning proposed solutions:
reusing the area when calling setWayGeometry of existing edge, if new point list is smaller
I think this might be quite hard to implement correctly.
use only 2 or 3 bytes for the elevation data instead of 4
I think this is a pretty good idea. Who needs elevation with 32-bit precision?
use negative values too (convert into 'unsigned int' -> long)
I guess this is already done.
I think 16-bit elevation would be the easiest to get start with, it would give ca. 2 bytes per point (1/6 if I get it correctly).
But an ultimate solution would be to make the length of geoRef configurable so that you could use 32 bit on smaller datasets and 48 or 64 on larger datasets.
reusing the area when calling setWayGeometry of existing edge, if new point list is smaller
Sorry, I got this now. This must be quite easy. Basically get geoRef and count like in fetchWayGeometry_ and if count is less than number of current points in the list, write the new array over existing geoRef.
This help with most update operations (unless PointList grows). This is why you've pointed me to this in #713. If I update elevations in post-processing step, this will use a lot of new geo-refs. Got it.
Is the problem that geoRef is stored as unsigned int?
Yes, kind of. In Java everything is signed so we only have 2^31 ... using the full int already save us for the several next years :)
Or is there a limit of DataAccess size like 4GB file size or something?
DataAccess is designed to grow efficient and to a big size. The functionality is basically a big array (but not limited to an integer size like array) and it also does not have the ugliness of e.g. an ArrayList to grow memory inefficient (allocate new and copy). Instead it starts with 1MB and just adds more segments if necessary. So you can grow to 1MB*2^31=2048TB if I have correctly calculated, also you can increase or decrease the segment size. Furthermore you can switch easily between the implementations (in-memory vs. memory mapped)
without significantly increasing the size of the edge storage. Or am I missing something?
This is correct, yes. But the storage is not that efficient at the moment (ask people using this for offline routing :)) and I would avoid to bloat it more. Instead I would prefer to make the geometry more compact.
This actually does not increase the possible space of geoRef but reduces the rate of geoRef growth, right?
Yes
I guess this is already done.
To be honest, I'm not 100% sure. Will have to check again.
But an ultimate solution would be to make the length of geoRef configurable so that you could use 32 bit on smaller datasets and 48 or 64 on larger datasets.
This would be nice but is currently not possible. E.g. it would also nice to have not 4 but 5 bytes for edgeIds as we could run out of IDs in some (dozen?) years. Dynamic length of pointers is not possible because every edge is basically a row in the edges DataAccess and the row length is static. Of course we could point into some dynamic edge area like we are already doing for the geometry but these indirections also costs a bit performance.
If I update elevations in post-processing step, this will use a lot of new geo-refs. Got it.
Is it possible that this problem came back with increase of OSM data?
I have graphopper version 0.6 with applied fix: dfd62e2 which increases limit to 2^32. I tested graphopper on linked real world test and it worked.
I'm importing world planet file and everything worked until this week. I can't import OSM data from 2019 10 13 anymore because java.lang.IllegalArgumentException: new capacity has to be strictly positive at com.graphhopper.storage.RAMDataAccess.ensureCapacity(RAMDataAccess.java:99) at com.graphhopper.storage.BaseGraph.ensureGeometry(BaseGraph.java:984) at com.graphhopper.storage.BaseGraph.setWayGeometryAtGeoRef(BaseGraph.java:864) at com.graphhopper.storage.BaseGraph.setWayGeometry_(BaseGraph.java:851) at com.graphhopper.storage.BaseGraph.access$100(BaseGraph.java:46) at com.graphhopper.storage.BaseGraph$CommonEdgeIterator.setWayGeometry(BaseGraph.java:1294)
And maxGeoRef in Base graph is -2 147 483 139 after this exception
Here are values at the point of exception:
14:22:03.584 WARN main d.k.w.importer.OSMReader: EdgeID: 301415499, pillarNodes:169 geo_max:-2147483139
14:22:03.584 WARN main d.k.w.importer.OSMReader: Counter:162710476 pillarNodesCount:661591226 (sums all pillarNodes in storeWayGeometry function)
14:22:03.584 WARN main d.k.w.importer.OSMReader: Simplify removed 64 nodes
14:22:03.584 WARN main d.k.w.importer.OSMReader: edges:301 415 500(10349MB), nodes:233 521 524(3564MB), name:(546MB), geo:-2 147 483 139(8193MB), bounds:-180.0,180.0,-79.81499965820461,83.66130796062889,-965.31,8793.5
I'm looking if there is problem in my code (the problem is any change takes 6 hours to run, because world is big), but code for importing graph didn't change at all during this and previous import in September the only thing that could be the issue is broken creation of planet file which is also custom code.
But same planet file can be imported when setWayPointMaxDistance is set on 6 (instead of 3) on OSMReader.
And this import has this values at the end:
imported graph dimensions|RAM_STORE|3D|NoExt|4,12,3,2,2, details:edges:302 220 812(10376MB), nodes:233 672 258(3566MB), name:(546MB), geo:1 757 760 817(6706MB), bounds:-180.0,180.0,-79.81499965820461,83.66130796062889,-965.31,8793.5
I think OSM world dataset has reached a point where 32 bits are no longer enough.
I've tried to import world dump from April 5th with the latest master branch and it fails with the following exception:
java.lang.RuntimeException: Could not parse OSM file: /home/bonk/import/import/planet-latest.osm.pbf
at com.graphhopper.reader.osm.WaySegmentParser.readOSM(WaySegmentParser.java:406)
at com.graphhopper.reader.osm.WaySegmentParser.readOSM(WaySegmentParser.java:107)
at com.graphhopper.reader.osm.OSMReader.readGraph(OSMReader.java:177)
at com.graphhopper.GraphHopper.importOSM(GraphHopper.java:910)
at com.graphhopper.GraphHopper.process(GraphHopper.java:812)
at com.graphhopper.GraphHopper.importAndClose(GraphHopper.java:776)
at com.graphhopper.application.cli.ImportCommand.run(ImportCommand.java:36)
at com.graphhopper.application.cli.ImportCommand.run(ImportCommand.java:27)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:98)
at io.dropwizard.cli.Cli.run(Cli.java:78)
at io.dropwizard.Application.run(Application.java:94)
at com.graphhopper.application.GraphHopperApplication.main(GraphHopperApplication.java:38)
Caused by: java.lang.IllegalStateException: Geometry too large, does not fit in 32 bits 4294967319
at com.graphhopper.storage.BaseGraph.nextGeoRef(BaseGraph.java:503)
at com.graphhopper.storage.BaseGraph.setWayGeometry_(BaseGraph.java:367)
at com.graphhopper.storage.BaseGraph$EdgeIteratorStateImpl.setWayGeometry(BaseGraph.java:931)
at com.graphhopper.reader.osm.OSMReader.addEdge(OSMReader.java:383)
at com.graphhopper.reader.osm.WaySegmentParser$Pass2Handler.handleSegment(WaySegmentParser.java:370)
at com.graphhopper.reader.osm.WaySegmentParser$Pass2Handler.splitSegmentAtSplitNodes(WaySegmentParser.java:341)
at com.graphhopper.reader.osm.WaySegmentParser$Pass2Handler.splitLoopSegments(WaySegmentParser.java:299)
at com.graphhopper.reader.osm.WaySegmentParser$Pass2Handler.splitWayAtJunctionsAndEmptySections(WaySegmentParser.java:274)
at com.graphhopper.reader.osm.WaySegmentParser$Pass2Handler.handleWay(WaySegmentParser.java:256)
at com.graphhopper.reader.osm.WaySegmentParser$ReaderElementHandler.handleElement(WaySegmentParser.java:501)
at com.graphhopper.reader.osm.WaySegmentParser.readOSM(WaySegmentParser.java:401)
... 11 more
Is anybody else experiencing this issue? My last successful world import was somewhere around mid February.
Ok yes this could be it. For graphhopper.com we are running up to date planet imports without this issue, but you might have hit the limit because of the long edge sampling. Did you check how large the geo ref value gets without the sampling?
I increased the size of the geo ref from four to eight bytes here: f18c122
This is certainly not the most memory efficient solution and five bytes should already be enough. The memory increase is four bytes per edge, so something like 3-4GB for the planet import. I haven't tested this yet, but if you could try the planet import with your settings again that would be very helpful.
Did you check how large the geo ref value gets without the sampling?
I've tried to disable sampling (comment out sampling parameters and disabled bilinear interpolation) and got the following:
geo:3,824,033,340(14588MB)
With sampling distance = 20 it was:
geo:4,273,074,032(16301MB)
I increased the size of the geo ref from four to eight bytes here: f18c122 This is certainly not the most memory efficient solution and five bytes should already be enough. The memory increase is four bytes per edge, so something like 3-4GB for the planet import. I haven't tested this yet, but if you could try the planet import with your settings again that would be very helpful.
Activity
use negative numbers to store larger geometry. weakens #500
karussell commentedon Dec 1, 2015
We increased the limit to (2^32-1) which makes this issue a lot less critical, this could only be tested via some unit test and this real world test. Will still let it open.
highsource commentedon Aug 17, 2016
Hi,
I'm trying to get my head around this issue.
From what I see in
BaseGraph, it usesDataAccess(a kind of abstract byte storage) to save bytes.PointListgets encoded into a list oflat,lonand possiblyele, 4 bytes each which are then saved inwayGeometryaltogether as a byte array.I'm not quite sure where the limit is. Is it the type of
geoRef? I see this:Is the problem that
geoRefis stored as unsigned int? Why can't we store it as long instead? Probably because it will add 4 bytes per edge and that would be too much of memory? How many edges do we have? If it's only 178 094 237 (not sure about the number above), 4 extra bytes per edge will be around 700 MB, that does not seem too much.We can add just one or two bytes if it's critical, that would increase the capacity to 2^40/2^48 which will be more than enough - without significantly increasing the size of the edge storage. Or am I missing something?
Or is there a limit of DataAccess size like 4GB file size or something?
This actually does not increase the possible space of
geoRefbut reduces the rate ofgeoRefgrowth, right? The size of the byte array of the point list will be smaller sogeoRefwill grow slower.I think we can win 1 bit if we don't save
len * dimbut justlen.dimis 2 or 3 so this would give at least 1 bit.Concerning proposed solutions:
I think this might be quite hard to implement correctly.
Quite an approach.
I think this is a pretty good idea. Who needs elevation with 32-bit precision?
I guess this is already done.
I think 16-bit elevation would be the easiest to get start with, it would give ca. 2 bytes per point (1/6 if I get it correctly).
But an ultimate solution would be to make the length of
geoRefconfigurable so that you could use 32 bit on smaller datasets and 48 or 64 on larger datasets.Please let me know if I'm on the right track.
Best wishes,
Alexey
highsource commentedon Aug 17, 2016
Sorry, I got this now. This must be quite easy. Basically get
geoRefandcountlike infetchWayGeometry_and ifcountis less than number of current points in the list, write the new array over existinggeoRef.This help with most update operations (unless
PointListgrows). This is why you've pointed me to this in #713. If I update elevations in post-processing step, this will use a lot of new geo-refs. Got it.I think I'll give it a try.
karussell commentedon Aug 17, 2016
Yes, kind of. In Java everything is signed so we only have 2^31 ... using the full int already save us for the several next years :)
DataAccess is designed to grow efficient and to a big size. The functionality is basically a big array (but not limited to an integer size like array) and it also does not have the ugliness of e.g. an ArrayList to grow memory inefficient (allocate new and copy). Instead it starts with 1MB and just adds more segments if necessary. So you can grow to 1MB*2^31=2048TB if I have correctly calculated, also you can increase or decrease the segment size. Furthermore you can switch easily between the implementations (in-memory vs. memory mapped)
This is correct, yes. But the storage is not that efficient at the moment (ask people using this for offline routing :)) and I would avoid to bloat it more. Instead I would prefer to make the geometry more compact.
Yes
To be honest, I'm not 100% sure. Will have to check again.
This would be nice but is currently not possible. E.g. it would also nice to have not 4 but 5 bytes for edgeIds as we could run out of IDs in some (dozen?) years. Dynamic length of pointers is not possible because every edge is basically a row in the edges DataAccess and the row length is static. Of course we could point into some dynamic edge area like we are already doing for the geometry but these indirections also costs a bit performance.
Yes & 👍 !
Please keep asking if something is unclear :) !
karussell commentedon Aug 17, 2016
See also this discussion comment
karussell commentedon Aug 18, 2016
Ups, I have indeed already fixed the 2^31 limit, see this comment with a real world test case #500 (comment)
So the limit is now 2^32 which is a lot less critical (several years with the current ~10% grow of OSM per year)
Solves #500 partial by reusing the geometry area of existing edge if …
Applied commit from graphopper to fix 2^31 limit
buma commentedon Oct 16, 2019
Is it possible that this problem came back with increase of OSM data?
I have graphopper version 0.6 with applied fix: dfd62e2 which increases limit to 2^32. I tested graphopper on linked real world test and it worked.
I'm importing world planet file and everything worked until this week. I can't import OSM data from 2019 10 13 anymore because
java.lang.IllegalArgumentException: new capacity has to be strictly positive at com.graphhopper.storage.RAMDataAccess.ensureCapacity(RAMDataAccess.java:99) at com.graphhopper.storage.BaseGraph.ensureGeometry(BaseGraph.java:984) at com.graphhopper.storage.BaseGraph.setWayGeometryAtGeoRef(BaseGraph.java:864) at com.graphhopper.storage.BaseGraph.setWayGeometry_(BaseGraph.java:851) at com.graphhopper.storage.BaseGraph.access$100(BaseGraph.java:46) at com.graphhopper.storage.BaseGraph$CommonEdgeIterator.setWayGeometry(BaseGraph.java:1294)And maxGeoRef in Base graph is -2 147 483 139 after this exception
Here are values at the point of exception:
14:22:03.584 WARN main d.k.w.importer.OSMReader: EdgeID: 301415499, pillarNodes:169 geo_max:-2147483139
14:22:03.584 WARN main d.k.w.importer.OSMReader: Counter:162710476 pillarNodesCount:661591226 (sums all pillarNodes in storeWayGeometry function)
14:22:03.584 WARN main d.k.w.importer.OSMReader: Simplify removed 64 nodes
14:22:03.584 WARN main d.k.w.importer.OSMReader: edges:301 415 500(10349MB), nodes:233 521 524(3564MB), name:(546MB), geo:-2 147 483 139(8193MB), bounds:-180.0,180.0,-79.81499965820461,83.66130796062889,-965.31,8793.5
I'm looking if there is problem in my code (the problem is any change takes 6 hours to run, because world is big), but code for importing graph didn't change at all during this and previous import in September the only thing that could be the issue is broken creation of planet file which is also custom code.
But same planet file can be imported when setWayPointMaxDistance is set on 6 (instead of 3) on OSMReader.
And this import has this values at the end:
imported graph dimensions|RAM_STORE|3D|NoExt|4,12,3,2,2, details:edges:302 220 812(10376MB), nodes:233 672 258(3566MB), name:(546MB), geo:1 757 760 817(6706MB), bounds:-180.0,180.0,-79.81499965820461,83.66130796062889,-965.31,8793.5
2 remaining items
use negative numbers to store larger geometry. weakens graphhopper#500
Solves graphhopper#500 partial by reusing the geometry area of existi…
[-]Geometry limited by 2^31[/-][+]Geometry limited by (2^32-1)[/+][-]Geometry limited by (2^32-1)[/-][+]Geometry limited by 2^32-1[/+]huco commentedon Apr 6, 2024
I think OSM world dataset has reached a point where 32 bits are no longer enough.
I've tried to import world dump from April 5th with the latest master branch and it fails with the following exception:
Is anybody else experiencing this issue? My last successful world import was somewhere around mid February.
easbar commentedon Apr 6, 2024
Which settings/profiles/ignored_highways/config.yml did you use for this planet import?
huco commentedon Apr 8, 2024
I'm using:
I guess elevation settings exacerbate the issue; if I increase long_edge_sampling_distance = 20 planet import finishes successfully.
easbar commentedon Apr 8, 2024
Ok yes this could be it. For graphhopper.com we are running up to date planet imports without this issue, but you might have hit the limit because of the long edge sampling. Did you check how large the geo ref value gets without the sampling?
Use eight bytes for the geo ref, #500
easbar commentedon Apr 8, 2024
I increased the size of the geo ref from four to eight bytes here: f18c122
This is certainly not the most memory efficient solution and five bytes should already be enough. The memory increase is four bytes per edge, so something like 3-4GB for the planet import. I haven't tested this yet, but if you could try the planet import with your settings again that would be very helpful.
huco commentedon Apr 9, 2024
I've tried to disable sampling (comment out sampling parameters and disabled bilinear interpolation) and got the following:
geo:3,824,033,340(14588MB)
With sampling distance = 20 it was:
geo:4,273,074,032(16301MB)
I will try it out and report back.
Merge pull request #1 from graphhopper/geo_ref_8byte
huco commentedon Apr 11, 2024
I can confirm import completes successfully with my original settings. Thanks!
Use eight bytes for the geo ref (#2978)