SlideShare a Scribd company logo
1 of 24
Download to read offline
Speedrunning the
Open Street Map
osm2pgsql Loader
The Open Street Map and osm2pgsql Loader
● The Open Street Map project provides invaluable data that keeps
driving users toward the PostGIS and PostgreSQL stacks.
● Baseline Planet data set loader option osm2pgsql unrolls a 120GB
XML file (or 70GB PBM one) into up to a terabyte database.
Crunchy Benchmarking Labs
● Crunchy runs a set of benchmark labs focused on various
PostgreSQL community goals.
● I run a “Farm” focused on storage and regression testing, mainly with
comparisons of bare metal Linux and Mac laptops. Hardware visible
at https://browser.geekbench.com/user/232126
● Code published to pgbench-tools. Results and PG metrics written to
database. Graphs via various Python data analysis tools.
● PG15 testing : osm2pgsql is an alternate backend to pgbench.
Speedrunning: 5950X Ubuntu 22.04+PG15b4
test db GB hours change
7558 924 19 Baseline Ubuntu 20.04, osm2pgsql-1.2, ssd:Rocket 4 Plus 2TB
7564 924 17
7913 947 11 Ubuntu 20.04->22.04, osm2pgsql1.2->1.6
7914 948 12 shared_buffers:4194304->6291456
7915 947 11 Linux performance: power,read-ahead
7916 948 10
7917 1075 12 update planet
7919 980 13 update to PG15beta4
7921 980 14 checkpoint_timeout:300->3600;fsync:on->off;synchronous_commit:on->off
7922 980 15 checkpoint_timeout:3600->300;fsync:off->on;synchronous_commit:off->on
7923 980 15
osm2pgsql loading stages
Processing
Node(6959649k 663.5k/s)
Way(772748k 29.16k/s)
Relation(8931370 862.18/s)
● Derived or intermediate tables: COPY, CREATE TABLE AS, CREATE INDEX
(B-Tree).
● CREATE INDEX (PostGIS).
● Parallel index builds have greatly reduced the CPU bound periods.
● On SSD, single core performance predicts performance for over half
the runtime.
○ Intel’s Xeon line has long held the lead there.
AMD Socket AM4, Zen 1/2/3
3900X:
FOSSGIS e.V.
Ref CPU
Unicorn platform?
Speedrunning: under 8 hours
Full hstore tagging, single 7700X client/server, 64GB RAM, PG14.5
Processing: Node(7992268k 15399.4k/s) Way(895907k 215.41k/s) Relation(10329300 2008.4/s)
2022-11-12 17:07:32 [0] Reading input files done in 9822s (2h 43m 42s).
2022-11-12 17:07:32 [0] Processed 7992268937 nodes in 519s (8m 39s) - 15399k/s
2022-11-12 17:07:32 [0] Processed 895907075 ways in 4159s (1h 9m 19s) - 215k/s
2022-11-12 17:07:32 [0] Processed 10331346 relations in 5144s (1h 25m 44s) - 2k/s
2022-11-12 22:12:48 [0] Done postprocessing on table 'planet_osm_ways' in 14571s (4h 2m 51s)
2022-11-12 22:12:48 [0] Done postprocessing on table 'planet_osm_rels' in 98s (1m 38s)
2022-11-12 22:12:48 [0] All postprocessing on table 'planet_osm_point' done in 2237s (37m 17s).
2022-11-12 22:12:48 [0] All postprocessing on table 'planet_osm_line' done in 3387s (56m 27s).
2022-11-12 22:12:48 [0] All postprocessing on table 'planet_osm_polygon' done in 8340s (2h 19m 0s).
2022-11-12 22:12:48 [0] All postprocessing on table 'planet_osm_roads' done in 357s (5m 57s).
2022-11-12 22:12:48 [0] osm2pgsql took 28138s (7h 48m 58s) overall.
600 MB/s shared_buffers hits
100 MB/s PG->Linux reads
100 MB/s PG client backend writes
9 MB/s WAL writes
Disk I/O:
AMD 7700X 64GB
SSD: SK Hynix P41 Platinum 2TB
(7GB/s seq read, 6.5GB/s seq write, 1,300,000 IOPS)
Disk I/O: reads
Disk I/O: writes showing 1s bursts
Well known osm2pgsql tuning
https://osm2pgsql.org/doc/manual.html
https://wiki.openstreetmap.org/wiki/Osm2pgsql/benchmarks
● Use PBM input, shrinking download to 70GB.
● Use temporary flat file for Nodes
○ Currently 70GB and growing. Can leave on root SSD disk.
● Increase dedicated node cache memory in favor of almost
everything else.
Use PBM files instead of OSM [xml+bzip]
● Protocol buffer Binary Format vastly better.
● 7700X CPU adds AVX512 memory transfers.
○ Up to 74% better on simple memory-bound single core SELECT tests!!
CPU Memory k/s Secs Hours PBM k/s Minutes
3950X 128GB 474 16637 4.6 9759 14
5950X 128GB 682 11549 3.2 12468 11
7700X 64GB 784 10053 2.8 17077 8
osm2pgsql Memory Budgeting: 128GB RAM
Phase Dynamic memory Static memory
Nodes Node Cache: Up to 50GB Shared Buffers
Ways Same Up to 48GB
Relations Same
CTAS Work Mem: 1GB plenty
CREATE INDEX Maintenance Work Mem:
Up to 20GB
Sample import runs
128GB RAM:
osm2pgsql --create --slim -v -d gis 
--flat-nodes /var/lib/postgresql/node.db 
--cache 50000 --number-processes 2 
--hstore --hstore-add-index 
~postgresql/osm/planet-latest.osm.pbf
64GB RAM:
osm2pgsql --create --slim -v -d gis 
--flat-nodes /var/lib/postgresql/node.db 
--cache 36000 --number-processes 2
--hstore --hstore-add-index 
~postgresql/osm/planet-latest.osm.pbf
Server postgresql.conf stanzas
Common settings:
min_wal_size = 4GB
max_wal_size = 16GB
work_mem = 1GB
maintenance_work_mem = 20GB
64GB Server:
shared_buffers = 8GB
effective_cache_size = 48GB
128GB Server:
shared_buffers = 32GB
effective_cache_size = 80GB
Remove standard seatbelts
checkpoint_timeout = 60min
synchronous_commit = off
fsync = off
No replication?
wal_level = minimal
max_wal_senders = 0
Controversial adjustments
autovacuum = off
full_page_writes = off
● My results turn autovacuum off for a 4% gain
○ Standard trade-off for bulk loading
○ Not all hosting platforms allow this?
○ Workaround is to starve it of as many resources as you can
● Full page writes are a platform specific storage optimization
○ Most likely outcome 1% gain
○ Shouldn’t advise regular users to ever tinker with this one
Advanced tuning: Background Writer
Tuned for heavy writes:
bgwriter_delay = 10ms
bgwriter_lru_maxpages = 500
bgwriter_lru_multiplier = 4.0
Or just disable:
bgwriter_lru_maxpages = 0
checkpoint_flush_after=0 [new parameter]
Performance vs. growth: 2016-2022
Table 2016 2022 Multiplier
Nodes 3,374,717K 7,992,268K 2.4
Ways 349,883K 895,907K 2.6
Relations 4,238,333 10,329,300 2.4
Node rate 258K 15,399K 60
Way rate 27K 215k 8.0
Relation rate 226 2,008 8.9
NVMe Trimming
$ sudo fstrim -av
/skp41: 1.8 TiB (1950602321920 bytes) trimmed on /dev/nvme2n1p1
Aggressive discarding sample:
$ iostat –mx 1 /dev/nvme2n1
Device d/s dMB/s drqm/s %drqm d_await dareq-sz
nvme2n1 1989.60 250651.89 0.00 0.00 0.49 129004.59
Linux tuning
$ sudo blockdev --setra 4096 /dev/nvme2n1
$ sudo cpupower frequency-set --governor=performance
● Boot PCI3.0 SSD plus single PCI4.0 NVMe SSD for tests, no RAID.
● Using ext4 filesystem
○ COW filesystems might safely disable full_page_writes
● Setup Linux swap.
○ For single server installs, osm2pgsql memory peaks can wipe out the
database server.
○ 32GB used here for full Planet.
● Huge pages can be useful too. Hard to measure with single workload.
Linux tuning: dd speedups
CPU Governor Read-ahead dd Read
Powersave 256 4.3 GB/s
Powersave 4096 4.9 GB/s
Balanced 256 5.3 GB/s
Balanced 4096 6.4 GB/s
Performance 256 5.7 GB/s
Performance 4096 6.6 GB/s
AMD 7700X
SSD: SK Hynix P41 Platinum 2TB
(7GB/s seq read, 6.5GB/s seq write, 1,300,000 IOPS)
Next steps
● Mac testing (M1 Pro, M2 Air)
● Benchmark work created 32GB of Time Series data

More Related Content

What's hot

Scaling and Modernizing Data Platform with Databricks
Scaling and Modernizing Data Platform with DatabricksScaling and Modernizing Data Platform with Databricks
Scaling and Modernizing Data Platform with DatabricksDatabricks
 
Troubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming ReplicationTroubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming ReplicationAlexey Lesovsky
 
PostgreSQL + ZFS best practices
PostgreSQL + ZFS best practicesPostgreSQL + ZFS best practices
PostgreSQL + ZFS best practicesSean Chittenden
 
Apache Spark on Kubernetes Anirudh Ramanathan and Tim Chen
Apache Spark on Kubernetes Anirudh Ramanathan and Tim ChenApache Spark on Kubernetes Anirudh Ramanathan and Tim Chen
Apache Spark on Kubernetes Anirudh Ramanathan and Tim ChenDatabricks
 
Plugin-based IVI Architectures with Qt
Plugin-based IVI Architectures with Qt Plugin-based IVI Architectures with Qt
Plugin-based IVI Architectures with Qt ICS
 
Amazon EMR Deep Dive & Best Practices
Amazon EMR Deep Dive & Best PracticesAmazon EMR Deep Dive & Best Practices
Amazon EMR Deep Dive & Best PracticesAmazon Web Services
 
Introduction to elasticsearch
Introduction to elasticsearchIntroduction to elasticsearch
Introduction to elasticsearchhypto
 
RJB - another choice for Ruby and Java interoperability
RJB - another choice for Ruby and Java interoperabilityRJB - another choice for Ruby and Java interoperability
RJB - another choice for Ruby and Java interoperabilityAkio Tajima
 
Elastic Cloud: The best way to experience everything Elastic
Elastic Cloud: The best way to experience everything ElasticElastic Cloud: The best way to experience everything Elastic
Elastic Cloud: The best way to experience everything ElasticElasticsearch
 
Json in Postgres - the Roadmap
 Json in Postgres - the Roadmap Json in Postgres - the Roadmap
Json in Postgres - the RoadmapEDB
 
Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internalsKostas Tzoumas
 
Apache Flink Training: System Overview
Apache Flink Training: System OverviewApache Flink Training: System Overview
Apache Flink Training: System OverviewFlink Forward
 
Hadoop Query Performance Smackdown
Hadoop Query Performance SmackdownHadoop Query Performance Smackdown
Hadoop Query Performance SmackdownDataWorks Summit
 
NVIDIA vGPU - Introduction to NVIDIA Virtual GPU
NVIDIA vGPU - Introduction to NVIDIA Virtual GPUNVIDIA vGPU - Introduction to NVIDIA Virtual GPU
NVIDIA vGPU - Introduction to NVIDIA Virtual GPULee Bushen
 
How To Connect Spark To Your Own Datasource
How To Connect Spark To Your Own DatasourceHow To Connect Spark To Your Own Datasource
How To Connect Spark To Your Own DatasourceMongoDB
 
Group policy Best Practices
Group policy Best PracticesGroup policy Best Practices
Group policy Best PracticesRob Dunn
 
E-Commerce search with Elasticsearch
E-Commerce search with ElasticsearchE-Commerce search with Elasticsearch
E-Commerce search with ElasticsearchYevhen Shyshkin
 

What's hot (20)

Scaling and Modernizing Data Platform with Databricks
Scaling and Modernizing Data Platform with DatabricksScaling and Modernizing Data Platform with Databricks
Scaling and Modernizing Data Platform with Databricks
 
Troubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming ReplicationTroubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming Replication
 
PostgreSQL + ZFS best practices
PostgreSQL + ZFS best practicesPostgreSQL + ZFS best practices
PostgreSQL + ZFS best practices
 
Apache Spark on Kubernetes Anirudh Ramanathan and Tim Chen
Apache Spark on Kubernetes Anirudh Ramanathan and Tim ChenApache Spark on Kubernetes Anirudh Ramanathan and Tim Chen
Apache Spark on Kubernetes Anirudh Ramanathan and Tim Chen
 
Plugin-based IVI Architectures with Qt
Plugin-based IVI Architectures with Qt Plugin-based IVI Architectures with Qt
Plugin-based IVI Architectures with Qt
 
Amazon EMR Deep Dive & Best Practices
Amazon EMR Deep Dive & Best PracticesAmazon EMR Deep Dive & Best Practices
Amazon EMR Deep Dive & Best Practices
 
Introduction to elasticsearch
Introduction to elasticsearchIntroduction to elasticsearch
Introduction to elasticsearch
 
RJB - another choice for Ruby and Java interoperability
RJB - another choice for Ruby and Java interoperabilityRJB - another choice for Ruby and Java interoperability
RJB - another choice for Ruby and Java interoperability
 
Elastic Cloud: The best way to experience everything Elastic
Elastic Cloud: The best way to experience everything ElasticElastic Cloud: The best way to experience everything Elastic
Elastic Cloud: The best way to experience everything Elastic
 
Daos
DaosDaos
Daos
 
Json in Postgres - the Roadmap
 Json in Postgres - the Roadmap Json in Postgres - the Roadmap
Json in Postgres - the Roadmap
 
Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internals
 
Apache Flink Training: System Overview
Apache Flink Training: System OverviewApache Flink Training: System Overview
Apache Flink Training: System Overview
 
Hadoop Query Performance Smackdown
Hadoop Query Performance SmackdownHadoop Query Performance Smackdown
Hadoop Query Performance Smackdown
 
Dive into PySpark
Dive into PySparkDive into PySpark
Dive into PySpark
 
NVIDIA vGPU - Introduction to NVIDIA Virtual GPU
NVIDIA vGPU - Introduction to NVIDIA Virtual GPUNVIDIA vGPU - Introduction to NVIDIA Virtual GPU
NVIDIA vGPU - Introduction to NVIDIA Virtual GPU
 
Unix Basics For Testers
Unix Basics For TestersUnix Basics For Testers
Unix Basics For Testers
 
How To Connect Spark To Your Own Datasource
How To Connect Spark To Your Own DatasourceHow To Connect Spark To Your Own Datasource
How To Connect Spark To Your Own Datasource
 
Group policy Best Practices
Group policy Best PracticesGroup policy Best Practices
Group policy Best Practices
 
E-Commerce search with Elasticsearch
E-Commerce search with ElasticsearchE-Commerce search with Elasticsearch
E-Commerce search with Elasticsearch
 

Similar to Speedrunning the Open Street Map osm2pgsql Loader

R&D work on pre exascale HPC systems
R&D work on pre exascale HPC systemsR&D work on pre exascale HPC systems
R&D work on pre exascale HPC systemsJoshua Mora
 
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterAndrey Kudryavtsev
 
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...Anne Nicolas
 
Some analysis of BlueStore and RocksDB
Some analysis of BlueStore and RocksDBSome analysis of BlueStore and RocksDB
Some analysis of BlueStore and RocksDBXiao Yan Li
 
Experiences with Power 9 at A*STAR CRC
Experiences with Power 9 at A*STAR CRCExperiences with Power 9 at A*STAR CRC
Experiences with Power 9 at A*STAR CRCGanesan Narayanasamy
 
PostgreSQL performance archaeology
PostgreSQL performance archaeologyPostgreSQL performance archaeology
PostgreSQL performance archaeologyTomas Vondra
 
Open Source Data Deduplication
Open Source Data DeduplicationOpen Source Data Deduplication
Open Source Data DeduplicationRedWireServices
 
Hortonworks on IBM POWER Analytics / AI
Hortonworks on IBM POWER Analytics / AIHortonworks on IBM POWER Analytics / AI
Hortonworks on IBM POWER Analytics / AIDataWorks Summit
 
20170602_OSSummit_an_intelligent_storage
20170602_OSSummit_an_intelligent_storage20170602_OSSummit_an_intelligent_storage
20170602_OSSummit_an_intelligent_storageKohei KaiGai
 
Ceph Day New York 2014: Ceph, a physical perspective
Ceph Day New York 2014: Ceph, a physical perspective Ceph Day New York 2014: Ceph, a physical perspective
Ceph Day New York 2014: Ceph, a physical perspective Ceph Community
 
Kvm performance optimization for ubuntu
Kvm performance optimization for ubuntuKvm performance optimization for ubuntu
Kvm performance optimization for ubuntuSim Janghoon
 
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a FoeHaim Yadid
 
Red Hat Gluster Storage Performance
Red Hat Gluster Storage PerformanceRed Hat Gluster Storage Performance
Red Hat Gluster Storage PerformanceRed_Hat_Storage
 
Elasticsearch on Kubernetes
Elasticsearch on KubernetesElasticsearch on Kubernetes
Elasticsearch on KubernetesJoerg Henning
 
(ATS6-GS04) Performance Analysis of Accelrys Enterprise Platform 9.0 on IBM’s...
(ATS6-GS04) Performance Analysis of Accelrys Enterprise Platform 9.0 on IBM’s...(ATS6-GS04) Performance Analysis of Accelrys Enterprise Platform 9.0 on IBM’s...
(ATS6-GS04) Performance Analysis of Accelrys Enterprise Platform 9.0 on IBM’s...BIOVIA
 
Accelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket CacheAccelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket CacheNicolas Poggi
 
PowerEdge Rack and Tower Server Masters AMD Processors.pptx
PowerEdge Rack and Tower Server Masters AMD Processors.pptxPowerEdge Rack and Tower Server Masters AMD Processors.pptx
PowerEdge Rack and Tower Server Masters AMD Processors.pptxNeoKenj
 

Similar to Speedrunning the Open Street Map osm2pgsql Loader (20)

R&D work on pre exascale HPC systems
R&D work on pre exascale HPC systemsR&D work on pre exascale HPC systems
R&D work on pre exascale HPC systems
 
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
 
QNAP TS-832PX-4G.pdf
QNAP TS-832PX-4G.pdfQNAP TS-832PX-4G.pdf
QNAP TS-832PX-4G.pdf
 
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
 
Some analysis of BlueStore and RocksDB
Some analysis of BlueStore and RocksDBSome analysis of BlueStore and RocksDB
Some analysis of BlueStore and RocksDB
 
Experiences with Power 9 at A*STAR CRC
Experiences with Power 9 at A*STAR CRCExperiences with Power 9 at A*STAR CRC
Experiences with Power 9 at A*STAR CRC
 
PostgreSQL performance archaeology
PostgreSQL performance archaeologyPostgreSQL performance archaeology
PostgreSQL performance archaeology
 
Open Source Data Deduplication
Open Source Data DeduplicationOpen Source Data Deduplication
Open Source Data Deduplication
 
BURA Supercomputer
BURA SupercomputerBURA Supercomputer
BURA Supercomputer
 
Hortonworks on IBM POWER Analytics / AI
Hortonworks on IBM POWER Analytics / AIHortonworks on IBM POWER Analytics / AI
Hortonworks on IBM POWER Analytics / AI
 
20170602_OSSummit_an_intelligent_storage
20170602_OSSummit_an_intelligent_storage20170602_OSSummit_an_intelligent_storage
20170602_OSSummit_an_intelligent_storage
 
Ceph Day New York 2014: Ceph, a physical perspective
Ceph Day New York 2014: Ceph, a physical perspective Ceph Day New York 2014: Ceph, a physical perspective
Ceph Day New York 2014: Ceph, a physical perspective
 
Kvm performance optimization for ubuntu
Kvm performance optimization for ubuntuKvm performance optimization for ubuntu
Kvm performance optimization for ubuntu
 
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
 
Red Hat Gluster Storage Performance
Red Hat Gluster Storage PerformanceRed Hat Gluster Storage Performance
Red Hat Gluster Storage Performance
 
Elasticsearch on Kubernetes
Elasticsearch on KubernetesElasticsearch on Kubernetes
Elasticsearch on Kubernetes
 
(ATS6-GS04) Performance Analysis of Accelrys Enterprise Platform 9.0 on IBM’s...
(ATS6-GS04) Performance Analysis of Accelrys Enterprise Platform 9.0 on IBM’s...(ATS6-GS04) Performance Analysis of Accelrys Enterprise Platform 9.0 on IBM’s...
(ATS6-GS04) Performance Analysis of Accelrys Enterprise Platform 9.0 on IBM’s...
 
Accelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket CacheAccelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket Cache
 
PowerEdge Rack and Tower Server Masters AMD Processors.pptx
PowerEdge Rack and Tower Server Masters AMD Processors.pptxPowerEdge Rack and Tower Server Masters AMD Processors.pptx
PowerEdge Rack and Tower Server Masters AMD Processors.pptx
 
Tacc Infinite Memory Engine
Tacc Infinite Memory EngineTacc Infinite Memory Engine
Tacc Infinite Memory Engine
 

Recently uploaded

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 

Recently uploaded (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 

Speedrunning the Open Street Map osm2pgsql Loader

  • 1. Speedrunning the Open Street Map osm2pgsql Loader
  • 2. The Open Street Map and osm2pgsql Loader ● The Open Street Map project provides invaluable data that keeps driving users toward the PostGIS and PostgreSQL stacks. ● Baseline Planet data set loader option osm2pgsql unrolls a 120GB XML file (or 70GB PBM one) into up to a terabyte database.
  • 3. Crunchy Benchmarking Labs ● Crunchy runs a set of benchmark labs focused on various PostgreSQL community goals. ● I run a “Farm” focused on storage and regression testing, mainly with comparisons of bare metal Linux and Mac laptops. Hardware visible at https://browser.geekbench.com/user/232126 ● Code published to pgbench-tools. Results and PG metrics written to database. Graphs via various Python data analysis tools. ● PG15 testing : osm2pgsql is an alternate backend to pgbench.
  • 4. Speedrunning: 5950X Ubuntu 22.04+PG15b4 test db GB hours change 7558 924 19 Baseline Ubuntu 20.04, osm2pgsql-1.2, ssd:Rocket 4 Plus 2TB 7564 924 17 7913 947 11 Ubuntu 20.04->22.04, osm2pgsql1.2->1.6 7914 948 12 shared_buffers:4194304->6291456 7915 947 11 Linux performance: power,read-ahead 7916 948 10 7917 1075 12 update planet 7919 980 13 update to PG15beta4 7921 980 14 checkpoint_timeout:300->3600;fsync:on->off;synchronous_commit:on->off 7922 980 15 checkpoint_timeout:3600->300;fsync:off->on;synchronous_commit:off->on 7923 980 15
  • 5. osm2pgsql loading stages Processing Node(6959649k 663.5k/s) Way(772748k 29.16k/s) Relation(8931370 862.18/s) ● Derived or intermediate tables: COPY, CREATE TABLE AS, CREATE INDEX (B-Tree). ● CREATE INDEX (PostGIS). ● Parallel index builds have greatly reduced the CPU bound periods. ● On SSD, single core performance predicts performance for over half the runtime. ○ Intel’s Xeon line has long held the lead there.
  • 6. AMD Socket AM4, Zen 1/2/3 3900X: FOSSGIS e.V. Ref CPU
  • 8. Speedrunning: under 8 hours Full hstore tagging, single 7700X client/server, 64GB RAM, PG14.5 Processing: Node(7992268k 15399.4k/s) Way(895907k 215.41k/s) Relation(10329300 2008.4/s) 2022-11-12 17:07:32 [0] Reading input files done in 9822s (2h 43m 42s). 2022-11-12 17:07:32 [0] Processed 7992268937 nodes in 519s (8m 39s) - 15399k/s 2022-11-12 17:07:32 [0] Processed 895907075 ways in 4159s (1h 9m 19s) - 215k/s 2022-11-12 17:07:32 [0] Processed 10331346 relations in 5144s (1h 25m 44s) - 2k/s 2022-11-12 22:12:48 [0] Done postprocessing on table 'planet_osm_ways' in 14571s (4h 2m 51s) 2022-11-12 22:12:48 [0] Done postprocessing on table 'planet_osm_rels' in 98s (1m 38s) 2022-11-12 22:12:48 [0] All postprocessing on table 'planet_osm_point' done in 2237s (37m 17s). 2022-11-12 22:12:48 [0] All postprocessing on table 'planet_osm_line' done in 3387s (56m 27s). 2022-11-12 22:12:48 [0] All postprocessing on table 'planet_osm_polygon' done in 8340s (2h 19m 0s). 2022-11-12 22:12:48 [0] All postprocessing on table 'planet_osm_roads' done in 357s (5m 57s). 2022-11-12 22:12:48 [0] osm2pgsql took 28138s (7h 48m 58s) overall. 600 MB/s shared_buffers hits 100 MB/s PG->Linux reads 100 MB/s PG client backend writes 9 MB/s WAL writes
  • 9. Disk I/O: AMD 7700X 64GB SSD: SK Hynix P41 Platinum 2TB (7GB/s seq read, 6.5GB/s seq write, 1,300,000 IOPS)
  • 11. Disk I/O: writes showing 1s bursts
  • 12. Well known osm2pgsql tuning https://osm2pgsql.org/doc/manual.html https://wiki.openstreetmap.org/wiki/Osm2pgsql/benchmarks ● Use PBM input, shrinking download to 70GB. ● Use temporary flat file for Nodes ○ Currently 70GB and growing. Can leave on root SSD disk. ● Increase dedicated node cache memory in favor of almost everything else.
  • 13. Use PBM files instead of OSM [xml+bzip] ● Protocol buffer Binary Format vastly better. ● 7700X CPU adds AVX512 memory transfers. ○ Up to 74% better on simple memory-bound single core SELECT tests!! CPU Memory k/s Secs Hours PBM k/s Minutes 3950X 128GB 474 16637 4.6 9759 14 5950X 128GB 682 11549 3.2 12468 11 7700X 64GB 784 10053 2.8 17077 8
  • 14. osm2pgsql Memory Budgeting: 128GB RAM Phase Dynamic memory Static memory Nodes Node Cache: Up to 50GB Shared Buffers Ways Same Up to 48GB Relations Same CTAS Work Mem: 1GB plenty CREATE INDEX Maintenance Work Mem: Up to 20GB
  • 15. Sample import runs 128GB RAM: osm2pgsql --create --slim -v -d gis --flat-nodes /var/lib/postgresql/node.db --cache 50000 --number-processes 2 --hstore --hstore-add-index ~postgresql/osm/planet-latest.osm.pbf 64GB RAM: osm2pgsql --create --slim -v -d gis --flat-nodes /var/lib/postgresql/node.db --cache 36000 --number-processes 2 --hstore --hstore-add-index ~postgresql/osm/planet-latest.osm.pbf
  • 16. Server postgresql.conf stanzas Common settings: min_wal_size = 4GB max_wal_size = 16GB work_mem = 1GB maintenance_work_mem = 20GB 64GB Server: shared_buffers = 8GB effective_cache_size = 48GB 128GB Server: shared_buffers = 32GB effective_cache_size = 80GB
  • 17. Remove standard seatbelts checkpoint_timeout = 60min synchronous_commit = off fsync = off No replication? wal_level = minimal max_wal_senders = 0
  • 18. Controversial adjustments autovacuum = off full_page_writes = off ● My results turn autovacuum off for a 4% gain ○ Standard trade-off for bulk loading ○ Not all hosting platforms allow this? ○ Workaround is to starve it of as many resources as you can ● Full page writes are a platform specific storage optimization ○ Most likely outcome 1% gain ○ Shouldn’t advise regular users to ever tinker with this one
  • 19. Advanced tuning: Background Writer Tuned for heavy writes: bgwriter_delay = 10ms bgwriter_lru_maxpages = 500 bgwriter_lru_multiplier = 4.0 Or just disable: bgwriter_lru_maxpages = 0 checkpoint_flush_after=0 [new parameter]
  • 20. Performance vs. growth: 2016-2022 Table 2016 2022 Multiplier Nodes 3,374,717K 7,992,268K 2.4 Ways 349,883K 895,907K 2.6 Relations 4,238,333 10,329,300 2.4 Node rate 258K 15,399K 60 Way rate 27K 215k 8.0 Relation rate 226 2,008 8.9
  • 21. NVMe Trimming $ sudo fstrim -av /skp41: 1.8 TiB (1950602321920 bytes) trimmed on /dev/nvme2n1p1 Aggressive discarding sample: $ iostat –mx 1 /dev/nvme2n1 Device d/s dMB/s drqm/s %drqm d_await dareq-sz nvme2n1 1989.60 250651.89 0.00 0.00 0.49 129004.59
  • 22. Linux tuning $ sudo blockdev --setra 4096 /dev/nvme2n1 $ sudo cpupower frequency-set --governor=performance ● Boot PCI3.0 SSD plus single PCI4.0 NVMe SSD for tests, no RAID. ● Using ext4 filesystem ○ COW filesystems might safely disable full_page_writes ● Setup Linux swap. ○ For single server installs, osm2pgsql memory peaks can wipe out the database server. ○ 32GB used here for full Planet. ● Huge pages can be useful too. Hard to measure with single workload.
  • 23. Linux tuning: dd speedups CPU Governor Read-ahead dd Read Powersave 256 4.3 GB/s Powersave 4096 4.9 GB/s Balanced 256 5.3 GB/s Balanced 4096 6.4 GB/s Performance 256 5.7 GB/s Performance 4096 6.6 GB/s AMD 7700X SSD: SK Hynix P41 Platinum 2TB (7GB/s seq read, 6.5GB/s seq write, 1,300,000 IOPS)
  • 24. Next steps ● Mac testing (M1 Pro, M2 Air) ● Benchmark work created 32GB of Time Series data