Repository navigation
Closed
Description
According to my recent benchmarks the OSMReader spends about 25% of its execution time looking up node ids:
It should be enough to avoid some unnecessary lookups like here:
graphhopper/reader-osm/src/main/java/com/graphhopper/reader/osm/OSMReader.java
Lines 256 to 265 in ec53afe
| LongIntMap nodeFilter = getNodeMap(); | |
| ReaderElement item; | |
| while ((item = in.getNext()) != null) { | |
| switch (item.getType()) { | |
| case ReaderElement.NODE: | |
| if (nodeFilter.get(item.getId()) != EMPTY_NODE) { | |
| processNode((ReaderNode) item); | |
| } | |
| break; |
graphhopper/reader-osm/src/main/java/com/graphhopper/reader/osm/OSMReader.java
Lines 479 to 481 in ec53afe
| protected void processNode(ReaderNode node) { | |
| if (isInBounds(node)) { | |
| addNode(node); |
graphhopper/reader-osm/src/main/java/com/graphhopper/reader/osm/OSMReader.java
Lines 496 to 497 in ec53afe
| boolean addNode(ReaderNode node) { | |
| int nodeType = getNodeMap().get(node.getId()); |
We could pass the internal node id through and avoid the additional lookups.
Metadata
Metadata
Assignees
Labels
No labels

Activity
otbutz commentedon Nov 27, 2020
Tried to reduce the lookups and even switched to a LongIntHashMap but no significant difference.
A BloomFilter could probably help a lot if we create it based on the nodes in the preprocess step.
easbar commentedon Nov 2, 2021
I think since #2448 and 5a36977 there is not really potential to further reduce the number of lookups. Closing for now, but of course feel free to open again if you think otherwise.