Merge remote-tracking branch 'origin/master' into pass_function_object_by_ref

This commit is contained in:
Dennis 2024-05-23 14:42:40 +02:00
commit e7c1a77929
No known key found for this signature in database
GPG Key ID: 6937EAEA33A3FA5D
20 changed files with 299 additions and 150 deletions

View File

@ -31,11 +31,11 @@ jobs:
env: env:
BUILD_TYPE: Release BUILD_TYPE: Release
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: pip install "conan<2.0.0" - run: pip install "conan<2.0.0"
- run: conan --version - run: conan --version
- run: cmake --version - run: cmake --version
- uses: actions/setup-node@v3 - uses: actions/setup-node@v4
with: with:
node-version: 18 node-version: 18
- run: node --version - run: node --version
@ -47,7 +47,7 @@ jobs:
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
- run: npm install --ignore-scripts - run: npm install --ignore-scripts
- run: npm link --ignore-scripts - run: npm link --ignore-scripts
- uses: microsoft/setup-msbuild@v1.1 - uses: microsoft/setup-msbuild@v2
- name: Build - name: Build
run: | run: |
.\scripts\ci\windows-build.bat .\scripts\ci\windows-build.bat
@ -76,13 +76,13 @@ jobs:
format-taginfo-docs: format-taginfo-docs:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Use Node.js - name: Use Node.js
uses: actions/setup-node@v3 uses: actions/setup-node@v4
with: with:
node-version: 18 node-version: 18
- name: Enable Node.js cache - name: Enable Node.js cache
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.npm path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
@ -106,9 +106,9 @@ jobs:
continue-on-error: false continue-on-error: false
steps: steps:
- name: Check out the repo - name: Check out the repo
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Enable osm.pbf cache - name: Enable osm.pbf cache
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: berlin-latest.osm.pbf path: berlin-latest.osm.pbf
key: v1-berlin-osm-pbf key: v1-berlin-osm-pbf
@ -342,36 +342,36 @@ jobs:
OSRM_CONNECTION_RETRIES: ${{ matrix.OSRM_CONNECTION_RETRIES }} OSRM_CONNECTION_RETRIES: ${{ matrix.OSRM_CONNECTION_RETRIES }}
OSRM_CONNECTION_EXP_BACKOFF_COEF: ${{ matrix.OSRM_CONNECTION_EXP_BACKOFF_COEF }} OSRM_CONNECTION_EXP_BACKOFF_COEF: ${{ matrix.OSRM_CONNECTION_EXP_BACKOFF_COEF }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Build machine architecture - name: Build machine architecture
run: uname -m run: uname -m
- name: Use Node.js - name: Use Node.js
uses: actions/setup-node@v3 uses: actions/setup-node@v4
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
- name: Enable Node.js cache - name: Enable Node.js cache
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.npm path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: | restore-keys: |
${{ runner.os }}-node- ${{ runner.os }}-node-
- name: Enable compiler cache - name: Enable compiler cache
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.ccache path: ~/.ccache
key: ccache-${{ matrix.name }}-${{ github.sha }} key: ccache-${{ matrix.name }}-${{ github.sha }}
restore-keys: | restore-keys: |
ccache-${{ matrix.name }}- ccache-${{ matrix.name }}-
- name: Enable Conan cache - name: Enable Conan cache
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.conan path: ~/.conan
key: v9-conan-${{ matrix.name }}-${{ github.sha }} key: v9-conan-${{ matrix.name }}-${{ github.sha }}
restore-keys: | restore-keys: |
v9-conan-${{ matrix.name }}- v9-conan-${{ matrix.name }}-
- name: Enable test cache - name: Enable test cache
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ${{github.workspace}}/test/cache path: ${{github.workspace}}/test/cache
key: v4-test-${{ matrix.name }}-${{ github.sha }} key: v4-test-${{ matrix.name }}-${{ github.sha }}
@ -511,7 +511,7 @@ jobs:
- name: Use Node 18 - name: Use Node 18
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }} if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
uses: actions/setup-node@v3 uses: actions/setup-node@v4
with: with:
node-version: 18 node-version: 18
- name: Run Node package tests on Node 18 - name: Run Node package tests on Node 18
@ -521,7 +521,7 @@ jobs:
npm run nodejs-tests npm run nodejs-tests
- name: Use Node 20 - name: Use Node 20
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }} if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
uses: actions/setup-node@v3 uses: actions/setup-node@v4
with: with:
node-version: 20 node-version: 20
- name: Run Node package tests on Node 20 - name: Run Node package tests on Node 20
@ -531,7 +531,7 @@ jobs:
npm run nodejs-tests npm run nodejs-tests
- name: Use Node latest - name: Use Node latest
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }} if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
uses: actions/setup-node@v3 uses: actions/setup-node@v4
with: with:
node-version: latest node-version: latest
- name: Run Node package tests on Node-latest - name: Run Node package tests on Node-latest
@ -541,7 +541,7 @@ jobs:
npm run nodejs-tests npm run nodejs-tests
- name: Upload test logs - name: Upload test logs
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
if: failure() if: failure()
with: with:
name: logs name: logs
@ -557,7 +557,7 @@ jobs:
# # Uploading report to CodeCov # # Uploading report to CodeCov
# - name: Upload code coverage # - name: Upload code coverage
# if: ${{ matrix.ENABLE_COVERAGE == 'ON' }} # if: ${{ matrix.ENABLE_COVERAGE == 'ON' }}
# uses: codecov/codecov-action@v1 # uses: codecov/codecov-action@v4
# with: # with:
# files: coverage.info # files: coverage.info
# name: codecov-osrm-backend # name: codecov-osrm-backend
@ -595,21 +595,21 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_REPOSITORY: ${{ github.repository }}
steps: steps:
- name: Enable compiler cache - name: Enable compiler cache
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.ccache path: ~/.ccache
key: v1-ccache-benchmarks-${{ github.sha }} key: v1-ccache-benchmarks-${{ github.sha }}
restore-keys: | restore-keys: |
v1-ccache-benchmarks- v1-ccache-benchmarks-
- name: Enable Conan cache - name: Enable Conan cache
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.conan path: ~/.conan
key: v1-conan-benchmarks-${{ github.sha }} key: v1-conan-benchmarks-${{ github.sha }}
restore-keys: | restore-keys: |
v1-conan-benchmarks- v1-conan-benchmarks-
- name: Checkout PR Branch - name: Checkout PR Branch
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
ref: ${{ github.head_ref }} ref: ${{ github.head_ref }}
path: pr path: pr
@ -624,7 +624,7 @@ jobs:
cd .. cd ..
make -C test/data make -C test/data
- name: Checkout Base Branch - name: Checkout Base Branch
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
ref: ${{ github.event.pull_request.base.ref }} ref: ${{ github.event.pull_request.base.ref }}
path: base path: base

View File

@ -7,6 +7,7 @@
- ADDED: Add support for opposite approach request parameter. [#6842](https://github.com/Project-OSRM/osrm-backend/pull/6842) - ADDED: Add support for opposite approach request parameter. [#6842](https://github.com/Project-OSRM/osrm-backend/pull/6842)
- ADDED: Add support for accessing edge flags in `process_segment` [#6658](https://github.com/Project-OSRM/osrm-backend/pull/6658) - ADDED: Add support for accessing edge flags in `process_segment` [#6658](https://github.com/Project-OSRM/osrm-backend/pull/6658)
- Build: - Build:
- CHANGED: Upgrade CI actions to latest versions [#6893](https://github.com/Project-OSRM/osrm-backend/pull/6893)
- ADDED: Add CI job which builds OSRM with gcc 12. [#6455](https://github.com/Project-OSRM/osrm-backend/pull/6455) - ADDED: Add CI job which builds OSRM with gcc 12. [#6455](https://github.com/Project-OSRM/osrm-backend/pull/6455)
- CHANGED: Upgrade to clang-tidy 15. [#6439](https://github.com/Project-OSRM/osrm-backend/pull/6439) - CHANGED: Upgrade to clang-tidy 15. [#6439](https://github.com/Project-OSRM/osrm-backend/pull/6439)
- CHANGED: Update actions/cache to v3. [#6420](https://github.com/Project-OSRM/osrm-backend/pull/6420) - CHANGED: Update actions/cache to v3. [#6420](https://github.com/Project-OSRM/osrm-backend/pull/6420)
@ -20,6 +21,7 @@
- CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452) - CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452)
- Misc: - Misc:
- CHANGED: Avoid copy of std::function-based callback in path unpacking [#6895](https://github.com/Project-OSRM/osrm-backend/pull/6895) - CHANGED: Avoid copy of std::function-based callback in path unpacking [#6895](https://github.com/Project-OSRM/osrm-backend/pull/6895)
- CHANGED: Replace boost::hash by std::hash [#6892](https://github.com/Project-OSRM/osrm-backend/pull/6892)
- CHANGED: Partial fix migration from boost::optional to std::optional [#6551](https://github.com/Project-OSRM/osrm-backend/issues/6551) - CHANGED: Partial fix migration from boost::optional to std::optional [#6551](https://github.com/Project-OSRM/osrm-backend/issues/6551)
- CHANGED: Update Conan Boost version to 1.85.0. [#6868](https://github.com/Project-OSRM/osrm-backend/pull/6868) - CHANGED: Update Conan Boost version to 1.85.0. [#6868](https://github.com/Project-OSRM/osrm-backend/pull/6868)
- FIXED: Fix an error in a RouteParameters AnnotationsType operator overload. [#6646](https://github.com/Project-OSRM/osrm-backend/pull/6646) - FIXED: Fix an error in a RouteParameters AnnotationsType operator overload. [#6646](https://github.com/Project-OSRM/osrm-backend/pull/6646)

View File

@ -3,11 +3,9 @@
#include "extractor/class_data.hpp" #include "extractor/class_data.hpp"
#include "extractor/turn_lane_types.hpp" #include "extractor/turn_lane_types.hpp"
#include "util/std_hash.hpp"
#include "util/typedefs.hpp" #include "util/typedefs.hpp"
#include <boost/functional/hash.hpp>
#include <boost/optional/optional_fwd.hpp>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
@ -18,25 +16,6 @@ class Way;
class Relation; class Relation;
} // namespace osmium } // namespace osmium
namespace std
{
template <> struct hash<std::tuple<std::string, std::string, std::string, std::string, std::string>>
{
std::size_t operator()(
const std::tuple<std::string, std::string, std::string, std::string, std::string> &mk)
const noexcept
{
std::size_t seed = 0;
boost::hash_combine(seed, std::get<0>(mk));
boost::hash_combine(seed, std::get<1>(mk));
boost::hash_combine(seed, std::get<2>(mk));
boost::hash_combine(seed, std::get<3>(mk));
boost::hash_combine(seed, std::get<4>(mk));
return seed;
}
};
} // namespace std
namespace osrm::extractor namespace osrm::extractor
{ {

View File

@ -8,11 +8,13 @@
#include "turn_path.hpp" #include "turn_path.hpp"
#include "util/integer_range.hpp" #include "util/integer_range.hpp"
#include "util/log.hpp" #include "util/log.hpp"
#include "util/std_hash.hpp"
#include "util/vector_view.hpp" #include "util/vector_view.hpp"
#include <algorithm>
#include <boost/functional/hash.hpp>
#include <mapbox/variant.hpp> #include <mapbox/variant.hpp>
#include <algorithm>
namespace osrm::extractor namespace osrm::extractor
{ {
@ -147,7 +149,6 @@ struct UnresolvedManeuverOverride
namespace std namespace std
{ {
template <> struct hash<osrm::extractor::NodeBasedTurn> template <> struct hash<osrm::extractor::NodeBasedTurn>
{ {
using argument_type = osrm::extractor::NodeBasedTurn; using argument_type = osrm::extractor::NodeBasedTurn;
using result_type = std::size_t; using result_type = std::size_t;
@ -155,9 +156,9 @@ template <> struct hash<osrm::extractor::NodeBasedTurn>
{ {
std::size_t seed = 0; std::size_t seed = 0;
boost::hash_combine(seed, s.from); hash_combine(seed, s.from);
boost::hash_combine(seed, s.via); hash_combine(seed, s.via);
boost::hash_combine(seed, s.to); hash_combine(seed, s.to);
return seed; return seed;
} }

View File

@ -1,10 +1,11 @@
#ifndef OSRM_EXTRACTOR_TRAFFIC_SIGNALS_HPP #ifndef OSRM_EXTRACTOR_TRAFFIC_SIGNALS_HPP
#define OSRM_EXTRACTOR_TRAFFIC_SIGNALS_HPP #define OSRM_EXTRACTOR_TRAFFIC_SIGNALS_HPP
#include "util/std_hash.hpp"
#include "util/typedefs.hpp" #include "util/typedefs.hpp"
#include <boost/functional/hash.hpp>
#include <unordered_set> #include <unordered_set>
#include <utility>
namespace osrm::extractor namespace osrm::extractor
{ {
@ -12,8 +13,7 @@ namespace osrm::extractor
struct TrafficSignals struct TrafficSignals
{ {
std::unordered_set<NodeID> bidirectional_nodes; std::unordered_set<NodeID> bidirectional_nodes;
std::unordered_set<std::pair<NodeID, NodeID>, boost::hash<std::pair<NodeID, NodeID>>> std::unordered_set<std::pair<NodeID, NodeID>> unidirectional_segments;
unidirectional_segments;
inline bool HasSignal(NodeID from, NodeID to) const inline bool HasSignal(NodeID from, NodeID to) const
{ {

View File

@ -3,10 +3,9 @@
#include "util/concurrent_id_map.hpp" #include "util/concurrent_id_map.hpp"
#include "util/integer_range.hpp" #include "util/integer_range.hpp"
#include "util/std_hash.hpp"
#include "util/typedefs.hpp" #include "util/typedefs.hpp"
#include <boost/functional/hash.hpp>
#include <bitset> #include <bitset>
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
@ -54,19 +53,7 @@ const constexpr Mask merge_to_right = 1u << 10u;
using TurnLaneDescription = std::vector<TurnLaneType::Mask>; using TurnLaneDescription = std::vector<TurnLaneType::Mask>;
// hash function for TurnLaneDescription using LaneDescriptionMap = util::ConcurrentIDMap<TurnLaneDescription, LaneDescriptionID>;
struct TurnLaneDescription_hash
{
std::size_t operator()(const TurnLaneDescription &lane_description) const
{
std::size_t seed = 0;
boost::hash_range(seed, lane_description.begin(), lane_description.end());
return seed;
}
};
using LaneDescriptionMap =
util::ConcurrentIDMap<TurnLaneDescription, LaneDescriptionID, TurnLaneDescription_hash>;
using TurnLanesIndexedArray = using TurnLanesIndexedArray =
std::tuple<std::vector<std::uint32_t>, std::vector<TurnLaneType::Mask>>; std::tuple<std::vector<std::uint32_t>, std::vector<TurnLaneType::Mask>>;

View File

@ -1,15 +1,14 @@
#ifndef OSRM_UTIL_GUIDANCE_BEARING_CLASS_HPP_ #ifndef OSRM_UTIL_GUIDANCE_BEARING_CLASS_HPP_
#define OSRM_UTIL_GUIDANCE_BEARING_CLASS_HPP_ #define OSRM_UTIL_GUIDANCE_BEARING_CLASS_HPP_
#include "util/std_hash.hpp"
#include "util/typedefs.hpp"
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <functional> #include <functional>
#include <vector> #include <vector>
#include <boost/functional/hash.hpp>
#include "util/typedefs.hpp"
namespace osrm::util::guidance namespace osrm::util::guidance
{ {
class BearingClass; class BearingClass;
@ -62,7 +61,10 @@ namespace std
inline size_t hash<::osrm::util::guidance::BearingClass>::operator()( inline size_t hash<::osrm::util::guidance::BearingClass>::operator()(
const ::osrm::util::guidance::BearingClass &bearing_class) const const ::osrm::util::guidance::BearingClass &bearing_class) const
{ {
return boost::hash_value(bearing_class.available_bearings); std::size_t value = 0;
hash_range(
value, bearing_class.available_bearings.cbegin(), bearing_class.available_bearings.cend());
return value;
} }
} // namespace std } // namespace std

View File

@ -1,36 +1,22 @@
#ifndef OSRM_UTIL_GUIDANCE_TURN_LANES_HPP #ifndef OSRM_UTIL_GUIDANCE_TURN_LANES_HPP
#define OSRM_UTIL_GUIDANCE_TURN_LANES_HPP #define OSRM_UTIL_GUIDANCE_TURN_LANES_HPP
#include "util/concurrent_id_map.hpp"
#include "util/std_hash.hpp"
#include "util/typedefs.hpp"
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <functional> #include <functional>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "util/concurrent_id_map.hpp"
#include "util/typedefs.hpp"
#include <boost/functional/hash.hpp>
namespace osrm::util::guidance namespace osrm::util::guidance
{ {
class LaneTuple; class LaneTuple;
class LaneTupleIdPair; class LaneTupleIdPair;
} // namespace osrm::util::guidance } // namespace osrm::util::guidance
namespace std
{
template <> struct hash<::osrm::util::guidance::LaneTuple>
{
inline std::size_t operator()(const ::osrm::util::guidance::LaneTuple &bearing_class) const;
};
template <> struct hash<::osrm::util::guidance::LaneTupleIdPair>
{
inline std::size_t
operator()(const ::osrm::util::guidance::LaneTupleIdPair &bearing_class) const;
};
} // namespace std
namespace osrm::util::guidance namespace osrm::util::guidance
{ {
@ -61,14 +47,6 @@ class LaneTuple
LaneID lanes_in_turn; LaneID lanes_in_turn;
LaneID first_lane_from_the_right; // is INVALID_LANEID when no lanes present LaneID first_lane_from_the_right; // is INVALID_LANEID when no lanes present
friend std::size_t hash_value(const LaneTuple &tup)
{
std::size_t seed{0};
boost::hash_combine(seed, tup.lanes_in_turn);
boost::hash_combine(seed, tup.first_lane_from_the_right);
return seed;
}
}; };
class LaneTupleIdPair class LaneTupleIdPair
@ -78,18 +56,36 @@ class LaneTupleIdPair
LaneDescriptionID second; LaneDescriptionID second;
bool operator==(const LaneTupleIdPair &other) const; bool operator==(const LaneTupleIdPair &other) const;
};
friend std::size_t hash_value(const LaneTupleIdPair &pair) using LaneDataIdMap = ConcurrentIDMap<LaneTupleIdPair, LaneDataID>;
} // namespace osrm::util::guidance
namespace std
{
template <> struct hash<::osrm::util::guidance::LaneTuple>
{
inline std::size_t operator()(const ::osrm::util::guidance::LaneTuple &lane_tuple) const
{ {
std::size_t seed{0}; std::size_t seed{0};
boost::hash_combine(seed, pair.first); hash_combine(seed, lane_tuple.lanes_in_turn);
boost::hash_combine(seed, pair.second); hash_combine(seed, lane_tuple.first_lane_from_the_right);
return seed; return seed;
} }
}; };
using LaneDataIdMap = ConcurrentIDMap<LaneTupleIdPair, LaneDataID, boost::hash<LaneTupleIdPair>>; template <> struct hash<::osrm::util::guidance::LaneTupleIdPair>
{
} // namespace osrm::util::guidance inline std::size_t
operator()(const ::osrm::util::guidance::LaneTupleIdPair &lane_tuple_id_pair) const
{
std::size_t seed{0};
hash_combine(seed, lane_tuple_id_pair.first);
hash_combine(seed, lane_tuple_id_pair.second);
return seed;
}
};
} // namespace std
#endif /* OSRM_UTIL_GUIDANCE_TURN_LANES_HPP */ #endif /* OSRM_UTIL_GUIDANCE_TURN_LANES_HPP */

View File

@ -1,7 +1,11 @@
#ifndef STD_HASH_HPP #ifndef STD_HASH_HPP
#define STD_HASH_HPP #define STD_HASH_HPP
#include <cstddef>
#include <functional> #include <functional>
#include <tuple>
#include <utility>
#include <vector>
// this is largely inspired by boost's hash combine as can be found in // this is largely inspired by boost's hash combine as can be found in
// "The C++ Standard Library" 2nd Edition. Nicolai M. Josuttis. 2012. // "The C++ Standard Library" 2nd Edition. Nicolai M. Josuttis. 2012.
@ -11,6 +15,14 @@ template <typename T> void hash_combine(std::size_t &seed, const T &val)
seed ^= std::hash<T>()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); seed ^= std::hash<T>()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
} }
template <typename It> void hash_range(std::size_t &seed, It first, const It last)
{
for (; first != last; ++first)
{
hash_combine(seed, *first);
}
}
template <typename T> void hash_val(std::size_t &seed, const T &val) { hash_combine(seed, val); } template <typename T> void hash_val(std::size_t &seed, const T &val) { hash_combine(seed, val); }
template <typename T, typename... Types> template <typename T, typename... Types>
@ -29,13 +41,39 @@ template <typename... Types> std::size_t hash_val(const Types &...args)
namespace std namespace std
{ {
template <typename... T> struct hash<std::tuple<T...>>
{
template <std::size_t... I>
static auto apply_tuple(const std::tuple<T...> &t, std::index_sequence<I...>)
{
std::size_t seed = 0;
return ((seed = hash_val(std::get<I>(t), seed)), ...);
}
auto operator()(const std::tuple<T...> &t) const
{
return apply_tuple(t, std::make_index_sequence<sizeof...(T)>());
}
};
template <typename T1, typename T2> struct hash<std::pair<T1, T2>> template <typename T1, typename T2> struct hash<std::pair<T1, T2>>
{ {
size_t operator()(const std::pair<T1, T2> &pair) const std::size_t operator()(const std::pair<T1, T2> &pair) const
{ {
return hash_val(pair.first, pair.second); return hash_val(pair.first, pair.second);
} }
}; };
template <typename T> struct hash<std::vector<T>>
{
auto operator()(const std::vector<T> &lane_description) const
{
std::size_t seed = 0;
hash_range(seed, lane_description.begin(), lane_description.end());
return seed;
}
};
} // namespace std } // namespace std
#endif // STD_HASH_HPP #endif // STD_HASH_HPP

View File

@ -364,7 +364,6 @@ const constexpr double SCALING_FACTOR = 4. / boost::math::constants::pi<double>(
inline double atan2_lookup(double y, double x) inline double atan2_lookup(double y, double x)
{ {
using namespace boost::math::constants; using namespace boost::math::constants;
if (std::abs(x) < std::numeric_limits<double>::epsilon()) if (std::abs(x) < std::numeric_limits<double>::epsilon())

View File

@ -13,6 +13,8 @@ function run_benchmarks_for_folder {
./$BENCHMARKS_FOLDER/match-bench "./$FOLDER/test/data/mld/monaco.osrm" mld > "$RESULTS_FOLDER/match_mld.bench" ./$BENCHMARKS_FOLDER/match-bench "./$FOLDER/test/data/mld/monaco.osrm" mld > "$RESULTS_FOLDER/match_mld.bench"
./$BENCHMARKS_FOLDER/match-bench "./$FOLDER/test/data/ch/monaco.osrm" ch > "$RESULTS_FOLDER/match_ch.bench" ./$BENCHMARKS_FOLDER/match-bench "./$FOLDER/test/data/ch/monaco.osrm" ch > "$RESULTS_FOLDER/match_ch.bench"
./$BENCHMARKS_FOLDER/route-bench "./$FOLDER/test/data/mld/monaco.osrm" mld > "$RESULTS_FOLDER/route_mld.bench" || true # TODO: remove `true` when this benchmark will be merged to master
./$BENCHMARKS_FOLDER/route-bench "./$FOLDER/test/data/ch/monaco.osrm" ch > "$RESULTS_FOLDER/route_ch.bench" || true # TODO: remove `true` when this benchmark will be merged to master
./$BENCHMARKS_FOLDER/alias-bench > "$RESULTS_FOLDER/alias.bench" ./$BENCHMARKS_FOLDER/alias-bench > "$RESULTS_FOLDER/alias.bench"
./$BENCHMARKS_FOLDER/json-render-bench "./$FOLDER/src/benchmarks/portugal_to_korea.json" > "$RESULTS_FOLDER/json-render.bench" ./$BENCHMARKS_FOLDER/json-render-bench "./$FOLDER/src/benchmarks/portugal_to_korea.json" > "$RESULTS_FOLDER/json-render.bench"
./$BENCHMARKS_FOLDER/packedvector-bench > "$RESULTS_FOLDER/packedvector.bench" ./$BENCHMARKS_FOLDER/packedvector-bench > "$RESULTS_FOLDER/packedvector.bench"

View File

@ -30,6 +30,18 @@ target_link_libraries(match-bench
${TBB_LIBRARIES} ${TBB_LIBRARIES}
${MAYBE_SHAPEFILE}) ${MAYBE_SHAPEFILE})
add_executable(route-bench
EXCLUDE_FROM_ALL
route.cpp
$<TARGET_OBJECTS:UTIL>)
target_link_libraries(route-bench
osrm
${BOOST_BASE_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${TBB_LIBRARIES}
${MAYBE_SHAPEFILE})
add_executable(json-render-bench add_executable(json-render-bench
EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL
json_render.cpp json_render.cpp
@ -72,5 +84,6 @@ add_custom_target(benchmarks
rtree-bench rtree-bench
packedvector-bench packedvector-bench
match-bench match-bench
route-bench
json-render-bench json-render-bench
alias-bench) alias-bench)

166
src/benchmarks/route.cpp Normal file
View File

@ -0,0 +1,166 @@
#include "engine/engine_config.hpp"
#include "util/coordinate.hpp"
#include "util/timing_util.hpp"
#include "osrm/route_parameters.hpp"
#include "osrm/coordinate.hpp"
#include "osrm/engine_config.hpp"
#include "osrm/json_container.hpp"
#include "osrm/osrm.hpp"
#include "osrm/status.hpp"
#include <boost/assert.hpp>
#include <boost/optional/optional.hpp>
#include <cstdlib>
#include <exception>
#include <iostream>
#include <optional>
#include <stdexcept>
#include <string>
#include <vector>
int main(int argc, const char *argv[])
try
{
if (argc < 2)
{
std::cerr << "Usage: " << argv[0] << " data.osrm\n";
return EXIT_FAILURE;
}
using namespace osrm;
// Configure based on a .osrm base path, and no datasets in shared mem from osrm-datastore
EngineConfig config;
config.storage_config = {argv[1]};
config.algorithm = (argc > 2 && std::string{argv[2]} == "mld") ? EngineConfig::Algorithm::MLD
: EngineConfig::Algorithm::CH;
config.use_shared_memory = false;
// Routing machine with several services (such as Route, Table, Nearest, Trip, Match)
OSRM osrm{config};
struct Benchmark
{
std::string name;
std::vector<util::Coordinate> coordinates;
RouteParameters::OverviewType overview;
bool steps = false;
std::optional<size_t> alternatives = std::nullopt;
std::optional<double> radius = std::nullopt;
};
auto run_benchmark = [&](const Benchmark &benchmark)
{
RouteParameters params;
params.overview = benchmark.overview;
params.steps = benchmark.steps;
params.coordinates = benchmark.coordinates;
if (benchmark.alternatives)
{
params.alternatives = *benchmark.alternatives;
}
if (benchmark.radius)
{
params.radiuses = std::vector<boost::optional<double>>(
params.coordinates.size(), boost::make_optional(*benchmark.radius));
}
TIMER_START(routes);
auto NUM = 1000;
for (int i = 0; i < NUM; ++i)
{
engine::api::ResultT result = json::Object();
const auto rc = osrm.Route(params, result);
auto &json_result = result.get<json::Object>();
if (rc != Status::Ok || json_result.values.find("routes") == json_result.values.end())
{
throw std::runtime_error{"Couldn't route"};
}
}
TIMER_STOP(routes);
std::cout << benchmark.name << std::endl;
std::cout << TIMER_MSEC(routes) << "ms" << std::endl;
std::cout << TIMER_MSEC(routes) / NUM << "ms/req" << std::endl;
};
std::vector<Benchmark> benchmarks = {
{"1000 routes, 3 coordinates, no alternatives, overview=full, steps=true",
{{FloatLongitude{7.437602352715465}, FloatLatitude{43.75030522209604}},
{FloatLongitude{7.421844922513342}, FloatLatitude{43.73690777888953}},
{FloatLongitude{7.412303912230966}, FloatLatitude{43.72851046529198}}},
RouteParameters::OverviewType::Full,
true,
std::nullopt},
{"1000 routes, 2 coordinates, no alternatives, overview=full, steps=true",
{{FloatLongitude{7.437602352715465}, FloatLatitude{43.75030522209604}},
{FloatLongitude{7.412303912230966}, FloatLatitude{43.72851046529198}}},
RouteParameters::OverviewType::Full,
true,
std::nullopt},
{"1000 routes, 2 coordinates, 3 alternatives, overview=full, steps=true",
{{FloatLongitude{7.437602352715465}, FloatLatitude{43.75030522209604}},
{FloatLongitude{7.412303912230966}, FloatLatitude{43.72851046529198}}},
RouteParameters::OverviewType::Full,
true,
3},
{"1000 routes, 3 coordinates, no alternatives, overview=false, steps=false",
{{FloatLongitude{7.437602352715465}, FloatLatitude{43.75030522209604}},
{FloatLongitude{7.421844922513342}, FloatLatitude{43.73690777888953}},
{FloatLongitude{7.412303912230966}, FloatLatitude{43.72851046529198}}},
RouteParameters::OverviewType::False,
false,
std::nullopt},
{"1000 routes, 2 coordinates, no alternatives, overview=false, steps=false",
{{FloatLongitude{7.437602352715465}, FloatLatitude{43.75030522209604}},
{FloatLongitude{7.412303912230966}, FloatLatitude{43.72851046529198}}},
RouteParameters::OverviewType::False,
false,
std::nullopt},
{"1000 routes, 2 coordinates, 3 alternatives, overview=false, steps=false",
{{FloatLongitude{7.437602352715465}, FloatLatitude{43.75030522209604}},
{FloatLongitude{7.412303912230966}, FloatLatitude{43.72851046529198}}},
RouteParameters::OverviewType::False,
false,
3},
{"1000 routes, 3 coordinates, no alternatives, overview=false, steps=false, radius=750",
{{FloatLongitude{7.437602352715465}, FloatLatitude{43.75030522209604}},
{FloatLongitude{7.421844922513342}, FloatLatitude{43.73690777888953}},
{FloatLongitude{7.412303912230966}, FloatLatitude{43.72851046529198}}},
RouteParameters::OverviewType::False,
false,
std::nullopt,
750},
{"1000 routes, 2 coordinates, no alternatives, overview=false, steps=false, radius=750",
{{FloatLongitude{7.437602352715465}, FloatLatitude{43.75030522209604}},
{FloatLongitude{7.412303912230966}, FloatLatitude{43.72851046529198}}},
RouteParameters::OverviewType::False,
false,
std::nullopt,
750},
{"1000 routes, 2 coordinates, 3 alternatives, overview=false, steps=false, radius=750",
{{FloatLongitude{7.437602352715465}, FloatLatitude{43.75030522209604}},
{FloatLongitude{7.412303912230966}, FloatLatitude{43.72851046529198}}},
RouteParameters::OverviewType::False,
false,
3,
750}
};
for (const auto &benchmark : benchmarks)
{
run_benchmark(benchmark);
}
return EXIT_SUCCESS;
}
catch (const std::exception &e)
{
std::cerr << "Error: " << e.what() << std::endl;
return EXIT_FAILURE;
}

View File

@ -19,7 +19,6 @@
#include "util/timing_util.hpp" #include "util/timing_util.hpp"
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/functional/hash.hpp>
#include <boost/numeric/conversion/cast.hpp> #include <boost/numeric/conversion/cast.hpp>
#include <algorithm> #include <algorithm>

View File

@ -13,6 +13,7 @@
#include "util/for_each_indexed.hpp" #include "util/for_each_indexed.hpp"
#include "util/for_each_pair.hpp" #include "util/for_each_pair.hpp"
#include "util/log.hpp" #include "util/log.hpp"
#include "util/std_hash.hpp"
#include "util/timing_util.hpp" #include "util/timing_util.hpp"
#include <boost/assert.hpp> #include <boost/assert.hpp>
@ -955,8 +956,7 @@ void ExtractionContainers::PrepareTrafficSignals(
TIMER_START(prepare_traffic_signals); TIMER_START(prepare_traffic_signals);
std::unordered_set<NodeID> bidirectional; std::unordered_set<NodeID> bidirectional;
std::unordered_set<std::pair<NodeID, NodeID>, boost::hash<std::pair<NodeID, NodeID>>> std::unordered_set<std::pair<NodeID, NodeID>> unidirectional;
unidirectional;
for (const auto &osm_node : bidirectional_signal_nodes) for (const auto &osm_node : bidirectional_signal_nodes)
{ {

View File

@ -18,6 +18,7 @@
#include "util/mmap_tar.hpp" #include "util/mmap_tar.hpp"
#include "util/opening_hours.hpp" #include "util/opening_hours.hpp"
#include "util/static_rtree.hpp" #include "util/static_rtree.hpp"
#include "util/std_hash.hpp"
#include "util/string_util.hpp" #include "util/string_util.hpp"
#include "util/timezones.hpp" #include "util/timezones.hpp"
#include "util/timing_util.hpp" #include "util/timing_util.hpp"
@ -42,25 +43,6 @@
#include <tuple> #include <tuple>
#include <vector> #include <vector>
namespace std
{
template <typename T1, typename T2, typename T3> struct hash<std::tuple<T1, T2, T3>>
{
size_t operator()(const std::tuple<T1, T2, T3> &t) const
{
return hash_val(std::get<0>(t), std::get<1>(t), std::get<2>(t));
}
};
template <typename T1, typename T2> struct hash<std::tuple<T1, T2>>
{
size_t operator()(const std::tuple<T1, T2> &t) const
{
return hash_val(std::get<0>(t), std::get<1>(t));
}
};
} // namespace std
namespace osrm::updater namespace osrm::updater
{ {
namespace namespace

@ -1 +0,0 @@
Subproject commit a351144a7aa6ca4b826295cd4454cd4ce3a6f71f

View File

@ -1,7 +1,6 @@
#include "util/bearing.hpp" #include "util/bearing.hpp"
#include "util/typedefs.hpp" #include "util/typedefs.hpp"
#include <boost/functional/hash.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(bearing_test) BOOST_AUTO_TEST_SUITE(bearing_test)

View File

@ -5,12 +5,12 @@
#include "util/coordinate_calculation.hpp" #include "util/coordinate_calculation.hpp"
#include "util/exception.hpp" #include "util/exception.hpp"
#include "util/rectangle.hpp" #include "util/rectangle.hpp"
#include "util/std_hash.hpp"
#include "util/typedefs.hpp" #include "util/typedefs.hpp"
#include "../common/temporary_file.hpp" #include "../common/temporary_file.hpp"
#include "mocks/mock_datafacade.hpp" #include "mocks/mock_datafacade.hpp"
#include <boost/functional/hash.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <cmath> #include <cmath>
@ -91,20 +91,6 @@ template <typename DataT> class LinearSearchNN
template <unsigned NUM_NODES, unsigned NUM_EDGES> struct RandomGraphFixture template <unsigned NUM_NODES, unsigned NUM_EDGES> struct RandomGraphFixture
{ {
struct TupleHash
{
using argument_type = std::pair<unsigned int, unsigned int>;
using result_type = std::size_t;
result_type operator()(const argument_type &t) const
{
std::size_t val{0};
boost::hash_combine(val, t.first);
boost::hash_combine(val, t.second);
return val;
}
};
RandomGraphFixture() RandomGraphFixture()
{ {
std::mt19937 g(RANDOM_SEED); std::mt19937 g(RANDOM_SEED);
@ -121,7 +107,7 @@ template <unsigned NUM_NODES, unsigned NUM_EDGES> struct RandomGraphFixture
std::uniform_int_distribution<> edge_udist(0, coords.size() - 1); std::uniform_int_distribution<> edge_udist(0, coords.size() - 1);
std::unordered_set<std::pair<unsigned, unsigned>, TupleHash> used_edges; std::unordered_set<std::pair<unsigned, unsigned>> used_edges;
while (edges.size() < NUM_EDGES) while (edges.size() < NUM_EDGES)
{ {

View File

@ -2,7 +2,6 @@
using namespace osrm::util; using namespace osrm::util;
#include <boost/functional/hash.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <iostream> #include <iostream>