diff --git a/generator/osm_source.cpp b/generator/osm_source.cpp index b0d216c..2f28c49 100644 --- a/generator/osm_source.cpp +++ b/generator/osm_source.cpp @@ -15,6 +15,7 @@ #include "base/file_name_utils.hpp" #include +#include #include #include #include @@ -253,7 +254,11 @@ void BuildIntermediateDataFromO5M( auto sourceMap = boost::iostreams::mapped_file_source{filename}; if (!sourceMap.is_open()) MYTHROW(Writer::OpenException, ("Failed to open", filename)); - ::madvise(const_cast(sourceMap.data()), sourceMap.size(), MADV_SEQUENTIAL); + // Try aggressively (MADV_WILLNEED) and asynchronously (std::launch::async) read ahead + // the o5m-file. + std::async(std::launch::async, [data = sourceMap.data(), size = sourceMap.size()] { + ::madvise(const_cast(data), size, MADV_WILLNEED); + }); constexpr size_t chunkSize = 10'000; std::vector threads;