Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Issue #77 introduced a regression in memory consumption in
InternalExtractorEdge
. This PR aimed to reduce memory consumption by using float type for the value and avoid the variant type. The float type can be used with assumption that initial edge weights and duration values from profiles have 24 significant bits (about 7 decimal digits). This is pretty safe assumption, because these values are used as 31 significant bits integers and summing up without precision loss 128 maximum possible values will lead to signed integer overflow. To route for over 128 edges without risk of the integer overflow edge weights should have less than 24 significant bits.The variant type introduces 8 bytes overhead by
std::size_t type_index
and results to sizeof(mapbox::util::variant<osrm::extractor::detail::ValueByEdge, osrm::extractor::detail::ValueByMeter>)= 16 bytes per
WeightData
or 32 bytes per edge. Because there are only two typesValueByEdge
that is always non-negative andValueByMeter
that is always strictly positive the sign bit can be used to encode the value type in a single value without values domains overlap.Structure sizes:
So PR saves 28 bytes per edge wrt to the current master (>11GB) and 4 bytes wrt master before #2399 merge (1.6GB) for raw 392418286 input ways.
Tasklist
Requirements / Relations
The PR is rebased on top of #3629, so only e6c884d commit is relevant for review.