Add support for disabling feature datasets (#6666)
This change adds support for disabling datasets, such that specific files are not loaded into memory when running OSRM. This enables users to not pay the memory cost for features they do not intend to use. Initially, there are two options: - ROUTE_GEOMETRY, for disabling overview, steps, annotations and waypoints. - ROUTE_STEPS, for disabling steps only. Attempts to query features for which the datasets are disabled will lead to a DisabledDatasetException being returned.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "util/meminfo.hpp"
|
||||
#include "util/version.hpp"
|
||||
|
||||
#include "osrm/datasets.hpp"
|
||||
#include "osrm/engine_config.hpp"
|
||||
#include "osrm/exception.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
@@ -23,7 +24,6 @@
|
||||
#include <exception>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
@@ -69,6 +69,7 @@ std::istream &operator>>(std::istream &in, EngineConfig::Algorithm &algorithm)
|
||||
throw util::RuntimeError(token, ErrorCode::UnknownAlgorithm, SOURCE_REF);
|
||||
return in;
|
||||
}
|
||||
|
||||
} // namespace osrm::engine
|
||||
|
||||
// overload validate for the double type to allow "unlimited" as an input
|
||||
@@ -155,6 +156,10 @@ inline unsigned generateServerProgramOptions(const int argc,
|
||||
value<EngineConfig::Algorithm>(&config.algorithm)
|
||||
->default_value(EngineConfig::Algorithm::CH, "CH"),
|
||||
"Algorithm to use for the data. Can be CH, CoreCH, MLD.") //
|
||||
("disable-feature-dataset",
|
||||
value<std::vector<storage::FeatureDataset>>(&config.disable_feature_dataset)->multitoken(),
|
||||
"Disables a feature dataset from being loaded into memory if not needed. Options: "
|
||||
"ROUTE_STEPS, ROUTE_GEOMETRY") //
|
||||
("max-viaroute-size",
|
||||
value<int>(&config.max_locations_viaroute)->default_value(500),
|
||||
"Max. locations supported in viaroute query") //
|
||||
@@ -276,7 +281,7 @@ try
|
||||
|
||||
if (!base_path.empty())
|
||||
{
|
||||
config.storage_config = storage::StorageConfig(base_path);
|
||||
config.storage_config = storage::StorageConfig(base_path, config.disable_feature_dataset);
|
||||
}
|
||||
if (!config.use_shared_memory && !config.storage_config.IsValid())
|
||||
{
|
||||
|
||||
+14
-3
@@ -2,6 +2,7 @@
|
||||
#include "storage/shared_memory.hpp"
|
||||
#include "storage/shared_monitor.hpp"
|
||||
#include "storage/storage.hpp"
|
||||
#include "osrm/storage_config.hpp"
|
||||
|
||||
#include "osrm/exception.hpp"
|
||||
#include "util/log.hpp"
|
||||
@@ -9,6 +10,7 @@
|
||||
#include "util/typedefs.hpp"
|
||||
#include "util/version.hpp"
|
||||
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
@@ -100,7 +102,8 @@ bool generateDataStoreOptions(const int argc,
|
||||
std::string &dataset_name,
|
||||
bool &list_datasets,
|
||||
bool &list_blocks,
|
||||
bool &only_metric)
|
||||
bool &only_metric,
|
||||
std::vector<storage::FeatureDataset> &disable_feature_dataset)
|
||||
{
|
||||
// declare a group of options that will be allowed only on command line
|
||||
boost::program_options::options_description generic_options("Options");
|
||||
@@ -125,6 +128,12 @@ bool generateDataStoreOptions(const int argc,
|
||||
boost::program_options::value<std::string>(&dataset_name)->default_value(""),
|
||||
"Name of the dataset to load into memory. This allows having multiple datasets in memory "
|
||||
"at the same time.") //
|
||||
("disable-feature-dataset",
|
||||
boost::program_options::value<std::vector<storage::FeatureDataset>>(
|
||||
&disable_feature_dataset)
|
||||
->multitoken(),
|
||||
"Disables a feature dataset from being loaded into memory if not needed. Options: "
|
||||
"ROUTE_STEPS, ROUTE_GEOMETRY") //
|
||||
("list",
|
||||
boost::program_options::value<bool>(&list_datasets)
|
||||
->default_value(false)
|
||||
@@ -239,6 +248,7 @@ try
|
||||
bool list_datasets = false;
|
||||
bool list_blocks = false;
|
||||
bool only_metric = false;
|
||||
std::vector<storage::FeatureDataset> disable_feature_dataset;
|
||||
if (!generateDataStoreOptions(argc,
|
||||
argv,
|
||||
verbosity,
|
||||
@@ -247,7 +257,8 @@ try
|
||||
dataset_name,
|
||||
list_datasets,
|
||||
list_blocks,
|
||||
only_metric))
|
||||
only_metric,
|
||||
disable_feature_dataset))
|
||||
{
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -260,7 +271,7 @@ try
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
storage::StorageConfig config(base_path);
|
||||
storage::StorageConfig config(base_path, disable_feature_dataset);
|
||||
if (!config.IsValid())
|
||||
{
|
||||
util::Log(logERROR) << "Config contains invalid file paths. Exiting!";
|
||||
|
||||
Reference in New Issue
Block a user