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

warn the user when using sub-optimal PBFs #601

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/read_pbf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,12 @@ int PbfReader::ReadPbfFile(unordered_set<string> const &nodeKeys, unsigned int t

std::map<std::size_t, std::pair< std::size_t, std::size_t> > blocks;

// Track the filesize - note that we can't rely on tellg(), as
// its meant to be an opaque token useful only for seeking.
size_t filesize = 0;
while (true) {
BlobHeader bh = readHeader(*infile);
filesize += bh.datasize();
if (infile->eof()) {
break;
}
Expand All @@ -327,6 +331,21 @@ int PbfReader::ReadPbfFile(unordered_set<string> const &nodeKeys, unsigned int t

std::size_t total_blocks = blocks.size();

// PBFs generated by Osmium have 8,000 entities per block,
// and each block is about 64KB.
//
// PBFs generated by osmconvert (e.g., BBBike PBFs) have as
// many entities as fit in 31MB. Each block is about 16MB.
//
// Osmium PBFs seem to be processed about 3x faster than osmconvert
// PBFs, so try to hint to the user when they could speed up their
// pipeline.
if (filesize / total_blocks > 1000000) {
std::cout << "warning: PBF has very large blocks, which may slow processing" << std::endl;
std::cout << " to fix: osmium cat -f pbf your-file.osm.pbf -o optimized.osm.pbf" << std::endl;
}


std::vector<ReadPhase> all_phases = { ReadPhase::Nodes, ReadPhase::RelationScan, ReadPhase::Ways, ReadPhase::Relations };
for(auto phase: all_phases) {
// Launch the pool with threadNum threads
Expand Down
Loading