From fbba23e66db6f45a89d972271325b9df1b87ef02 Mon Sep 17 00:00:00 2001 From: Kajari Ghosh Date: Mon, 12 Feb 2018 11:10:17 -0500 Subject: [PATCH] set up for computing durations while unpacking them copy dummy cache over implement retrievePackedPathFromSearchSpace calculate packed_path_from_source_to_middle debugging the retrievePackedPathFromSearchSpace function implementation adding in packed_path_from_source_to_middle cache is partway working unpack path and get duration that way the computeDurationForEdge method comment out cache clean up the code move vector creation and allocation to outside of loop hack to not return vectors on facade.GetUncompressedForwardDurations and facade.GetUncompressedReverseDurations clean up hack add exclude_index to cache key clearing cache with timestamp rebase against vectors->range pr swapped out unordered_map cache with a boost_lru implementation calculation for cache size cleaned up comment about cache size calculations unit tests cache uses unsigned char for exclude index clean up cache and unit tests pass in a hashed key to the threadlocal cache 500 mb threadlocal 2 t fixes and a rebase correct calculation --- features/testbot/distance_matrix.feature | 74 ++++++ include/engine/data_watchdog.hpp | 6 +- .../contiguous_internalmem_datafacade.hpp | 22 +- include/engine/datafacade_factory.hpp | 13 +- include/engine/datafacade_provider.hpp | 5 +- .../routing_algorithms/routing_base.hpp | 27 +++ .../routing_algorithms/routing_base_ch.hpp | 216 ++++++++++++++---- include/engine/search_engine_data.hpp | 5 + include/engine/unpacking_cache.hpp | 113 +++++++++ .../routing_algorithms/many_to_many_ch.cpp | 4 + src/engine/search_engine_data.cpp | 13 ++ third_party/compute_detail/lru_cache.hpp | 139 +++++++++++ unit_tests/engine/unpacking_cache.cpp | 86 +++++++ 13 files changed, 667 insertions(+), 56 deletions(-) create mode 100644 include/engine/unpacking_cache.hpp create mode 100644 third_party/compute_detail/lru_cache.hpp create mode 100644 unit_tests/engine/unpacking_cache.cpp diff --git a/features/testbot/distance_matrix.feature b/features/testbot/distance_matrix.feature index 104727350..7befc82e1 100644 --- a/features/testbot/distance_matrix.feature +++ b/features/testbot/distance_matrix.feature @@ -25,6 +25,80 @@ Feature: Basic Distance Matrix Given the query options | exclude | toll | + Scenario: Testbot - Travel time matrix of minimal network with excludes + Given the query options + | exclude | toll | + + Given the node map + """ + a b + c d + """ + + And the ways + | nodes | highway | toll | # | + | ab | motorway | | not drivable for exclude=motorway | + | cd | primary | | always drivable | + | ac | highway | yes | not drivable for exclude=motorway exclude=toll and exclude=motorway,toll | + | bd | highway | yes | not drivable for exclude=motorway exclude=toll | + + When I request a travel time matrix I should get + | | a | b | c | d | + | a | 0 | 15 | | | + | b | 15 | 0 | | | + | c | | | 0 | 10 | + | d | | | 10 | 0 | + + Scenario: Testbot - Travel time matrix of minimal network with different exclude + Given the query options + | exclude | motorway | + + Given the node map + """ + a b + c d + """ + + And the ways + | nodes | highway | toll | # | + | ab | motorway | | not drivable for exclude=motorway | + | cd | primary | | always drivable | + | ac | highway | yes | not drivable for exclude=motorway exclude=toll and exclude=motorway,toll | + | bd | highway | yes | not drivable for exclude=motorway exclude=toll | + + + When I request a travel time matrix I should get + | | a | b | c | d | + | a | 0 | 40 | 15 | 25 | + | b | 40 | 0 | 25 | 15 | + | c | 15 | 25 | 0 | 10 | + | d | 25 | 15 | 10 | 0 | + + Scenario: Testbot - Travel time matrix of minimal network with excludes combination + Given the query options + | exclude | motorway,toll | + + Given the node map + """ + a b + c d + """ + + And the ways + | nodes | highway | toll | # | + | ab | motorway | | not drivable for exclude=motorway | + | cd | primary | | always drivable | + | ac | highway | yes | not drivable for exclude=motorway exclude=toll and exclude=motorway,toll | + | bd | highway | yes | not drivable for exclude=motorway exclude=toll | + + When I request a travel time matrix I should get + | | a | b | c | d | + | a | 0 | 10 | 0 | 10 | + | b | 10 | 0 | 10 | 0 | + | c | 0 | 10 | 0 | 10 | + | d | 10 | 0 | 10 | 0 | + + Scenario: Testbot - Travel time matrix with different way speeds Given the node map """ a b diff --git a/include/engine/data_watchdog.hpp b/include/engine/data_watchdog.hpp index b44274545..a655c4a19 100644 --- a/include/engine/data_watchdog.hpp +++ b/include/engine/data_watchdog.hpp @@ -60,7 +60,8 @@ class DataWatchdogImpl( std::make_shared( std::vector{ - static_region.shm_key, updatable_region.shm_key})); + static_region.shm_key, updatable_region.shm_key}), + static_region.timestamp); } watcher = std::thread(&DataWatchdogImpl::Run, this); @@ -115,7 +116,8 @@ class DataWatchdogImpl( std::make_shared( std::vector{ - static_region.shm_key, updatable_region.shm_key})); + static_region.shm_key, updatable_region.shm_key}), + static_region.timestamp); } util::Log() << "DataWatchdog thread stopped"; diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index 6befce6d0..60aa57507 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -168,6 +168,8 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade // allocator that keeps the allocation data std::shared_ptr allocator; + std::size_t m_exclude_index; + unsigned m_timestamp; void InitializeInternalPointers(const storage::SharedDataIndex &index, const std::string &metric_name, @@ -183,6 +185,8 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade m_check_sum = *index.GetBlockPtr("/common/connectivity_checksum"); + m_exclude_index = exclude_index; + std::tie(m_coordinate_list, m_osmnodeid_list) = make_nbn_data_view(index, "/common/nbn_data"); @@ -217,12 +221,16 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade } public: + std::size_t GetTimestamp() const { return m_timestamp; } + std::size_t GetExcludeIndex() const { return m_exclude_index; } + // allows switching between process_memory/shared_memory datafacade, based on the type of // allocator ContiguousInternalMemoryDataFacadeBase(std::shared_ptr allocator_, const std::string &metric_name, - const std::size_t exclude_index) - : allocator(std::move(allocator_)) + const std::size_t exclude_index, + unsigned timestamp) + : allocator(std::move(allocator_)), m_timestamp(timestamp) { InitializeInternalPointers(allocator->GetIndex(), metric_name, exclude_index); } @@ -618,8 +626,9 @@ class ContiguousInternalMemoryDataFacade public: ContiguousInternalMemoryDataFacade(std::shared_ptr allocator, const std::string &metric_name, - const std::size_t exclude_index) - : ContiguousInternalMemoryDataFacadeBase(allocator, metric_name, exclude_index), + const std::size_t exclude_index, + unsigned timestamp) + : ContiguousInternalMemoryDataFacadeBase(allocator, metric_name, exclude_index, timestamp), ContiguousInternalMemoryAlgorithmDataFacade(allocator, metric_name, exclude_index) { } @@ -735,8 +744,9 @@ class ContiguousInternalMemoryDataFacade final public: ContiguousInternalMemoryDataFacade(std::shared_ptr allocator, const std::string &metric_name, - const std::size_t exclude_index) - : ContiguousInternalMemoryDataFacadeBase(allocator, metric_name, exclude_index), + const std::size_t exclude_index, + unsigned timestamp) + : ContiguousInternalMemoryDataFacadeBase(allocator, metric_name, exclude_index, timestamp), ContiguousInternalMemoryAlgorithmDataFacade(allocator, metric_name, exclude_index) { } diff --git a/include/engine/datafacade_factory.hpp b/include/engine/datafacade_factory.hpp index a4ff57f38..5b459f31c 100644 --- a/include/engine/datafacade_factory.hpp +++ b/include/engine/datafacade_factory.hpp @@ -30,8 +30,8 @@ template