Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement:maptool:improve processing speed and fix some memory holes #901

Merged
merged 6 commits into from
Oct 18, 2019

Conversation

metalstrolch
Copy link
Contributor

This pull request increases processing speed of maptool on large areas (world) by partly parallelizing the turn restriction processing as well as by introducing buffered read of nodes on relation processing.
Time saved on my box: -1day / ~20%

@jkoan
Copy link
Member

jkoan commented Oct 7, 2019

How many threads did you assigned on your tests and what would you suggest as a optimum if running with ryzen 2600 and NVMe ssd?

@metalstrolch
Copy link
Contributor Author

I used the now default of 8 threads. I wouldn't use many more because, with every thread, you split the resulting hash. I used 7GiB of slice size on a 16GiB RAM machine. Remember to do ulimit -s unlimited.

My machine is a core I7 NUC with a spinning USB attached disc. So I expect yours to be way faster. Unfortunately currently the disk speed doesn't help that much.

Some explanation:

On creating the hashes, you basically read all items in a common queue, and every thread hashes the next item it gets into its own private hash. As hashing scales bad with number of elements, this helps a lot because a: more processing power, and b: smaller hashes per cpu.

BUT:
On processing the hash, you have to try all items against all hashes! Sot the more threads you used before the slower that gets. Luckily using the hash scales way better. This can only be done by one thread currently, as most parts of maptool are not thread safe!

Additionally using your SSD, the smaller fix contained will help a lot, I think. instead of reading the coordinates (several billions in world) one by one from disk I added a buffer reading them several MiB at once and then serving them from the buffer. This helps most on turn restriction processing.

@metalstrolch
Copy link
Contributor Author

Somebody planning to test this or is already testing this? Works for me.

If no objections: Planning to merge on Friday 18th October 2019.

@gefin
Copy link
Contributor

gefin commented Oct 16, 2019

Sorry i cant test (map size>>device size)
I can test the planetextractor result after it is active...

@jkoan
Copy link
Member

jkoan commented Oct 16, 2019

Somebody planning to test this or is already testing this? Works for me.

If no objections: Planning to merge on Friday 18th October 2019.

Maptool running against pbf of Germany ;) Will show a comparison when finished

@metalstrolch
Copy link
Contributor Author

Cool. @jkoan . I'll await your result, Expect the order of some elements in the binfile to be different, because the threading shuffles the processing order a bit. Shouldn't matter much, as osm files are usually ordered by OSM ID, which is purely random in terms of map functionality as well.

@gefin Unfortunately I don't have a clue when this will hit planet extractor after merge, as I don't know any way to see maptool version used there. Hopefully we will never notice this pull request there.

@metalstrolch
Copy link
Contributor Author

Does anybody have a ready-made tool to extract regions out of a world binfile? While the algorithm is basically described in https://navit.readthedocs.io/en/latest/maps.html#binfile , it would stupid to reimplement something that seems to exist at least for planet extractor. Would help a lot to check #906

@jkoan
Copy link
Member

jkoan commented Oct 16, 2019

Does anybody have a ready-made tool to extract regions out of a world binfile? While the algorithm is basically described in https://navit.readthedocs.io/en/latest/maps.html#binfile , it would stupid to reimplement something that seems to exist at least for planet extractor. Would help a lot to check #906

i don't know a tool like this, but we plan to rewrite planet extractor anyway since its closed source and not maintainable. But this is something for another issue, not this PR

@metalstrolch
Copy link
Contributor Author

Bummer. Seems to be the reason why I never found the source for it.

@jkoan
Copy link
Member

jkoan commented Oct 16, 2019

version run num real user sys
trunk 1 41m15,070s 40m22,668s 1m55,011s
trunk 3 44m19,450s 42m38,990s 2m26,089s
maptool_turn_restriction_threading 2 39m8,376s 38m22,635s 1m59,468s
maptool_turn_restriction_threading 4 40m15,357s 38m50,225s 2m18,419s

Runs number 1&2 did run after each other. Run number 3 and 4 run at the same time (different dirs).
Command: maptool --protobuf -T $(nproc) -i germany-latest.osm.pbf germany-trunk2.bin
pbf-File: https://download.geofabrik.de/europe/germany-191015.osm.pbf

@metalstrolch
Copy link
Contributor Author

Merging this albeit it seems to be system dependent or dependent on the size of map file how much speed is gained. At least on my setup this saves around 20% processing time. At least some memory holes get fixed.

@metalstrolch metalstrolch merged commit f1c0429 into trunk Oct 18, 2019
@metalstrolch
Copy link
Contributor Author

Will keep the branch for a while for reference.

jkoan pushed a commit to jkoan/navit that referenced this pull request Oct 24, 2019
navit-gps#901)

* Convert turn relation processing to multi threaded
* Enhance item read function to block read the items for faster overall reading speed.
* Fix some memory holes found by valgrind. There are still many left. Specially in coastline and Country border code.
@metalstrolch metalstrolch deleted the maptool_turn_restriction_threading branch October 28, 2019 12:28
hoehnp pushed a commit that referenced this pull request Nov 4, 2019
#901)

* Convert turn relation processing to multi threaded
* Enhance item read function to block read the items for faster overall reading speed.
* Fix some memory holes found by valgrind. There are still many left. Specially in coastline and Country border code.
viktorgino pushed a commit that referenced this pull request Sep 22, 2020
#901)

* Convert turn relation processing to multi threaded
* Enhance item read function to block read the items for faster overall reading speed.
* Fix some memory holes found by valgrind. There are still many left. Specially in coastline and Country border code.
jkoan pushed a commit to jkoan/navit that referenced this pull request Jun 30, 2021
navit-gps#901)

* Convert turn relation processing to multi threaded
* Enhance item read function to block read the items for faster overall reading speed.
* Fix some memory holes found by valgrind. There are still many left. Specially in coastline and Country border code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants