-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add support for disabling feature datasets #6666
Conversation
include/storage/storage_config.hpp
Outdated
@@ -31,40 +31,79 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
#include <boost/filesystem/path.hpp> | |||
|
|||
#include "storage/io_config.hpp" | |||
#include "osrm/datasets.hpp" | |||
|
|||
#include "set" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit.
#include "set" | |
#include <set> |
include/util/exception.hpp
Outdated
{ | ||
} | ||
|
||
std::string Dataset() const { return dataset; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit.
std::string Dataset() const { return dataset; } | |
const std::string& Dataset() const { return dataset; } |
3b90f44
to
d34f259
Compare
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.
d34f259
to
189f6eb
Compare
For completeness, I ran performance tests using the same setup as here with the first three coordinate sets. All requests had the parameters The results show no change in performance with this PR. Tests with request parameters that disabled geometries and steps had the same outcome. |
Issue
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 a feature for which the dataset is disabled will lead to a
DisabledDatasetException
being returned.Full details are on a new wiki page: https://github.com/Project-OSRM/osrm-backend/wiki/Disabled-Datasets
Design Choices
The implementation separates the "feature dataset" concept from the actual files loaded into memory. This gives some flexibility in how the data is stored, allowing for changes in the file structure without breaking the user facing API.
The feature datasets to disable are passed as an array argument to
osrm-routed
,osrm-datastore
and the NodeJS engine configuration. Currently, you would only select at most one option (ROUTE_GEOMETRY
is a superset ofROUTE_STEPS
), but the array interface will allow us to add more options in the future whilst maintaining backwards compatibility.On every data facade call to optional datasets, we check a boolean to see if its loaded. I attempted other solutions that don't perform a check on every call, such as virtual functions and lambdas. These didn't improve performance and were significantly more complicated, so I stuck with the simplest implementation.
Performance
For a contraction hierarchy dataset,
--disable-feature-dataset ROUTE_GEOMETRY
reduces RAM usage by ~15%.There appears to be no impact on query performance. This is likely due to the number of data facade calls affected being very small. Will add full query performance results in a subsequent post.
Future Direction
Some optional datasets are stored in files with required datasets. One such example is OSM node IDs being stored with coordinates. We could reduce memory usage further when disabling
ROUTE_GEOMETRY
by splitting such files, or refactoring how files are loaded into memory.Tasklist
Requirements / Relations
#5218
#5838
#6045