Skip to content
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

Deprecate CoreCH, fallback to using CH #4598

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions features/options/contract/help.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Feature: osrm-contract command line options: help
And stdout should contain "Configuration:"
And stdout should contain "--threads"
And stdout should contain "--core"
And stdout should contain "--level-cache"
And stdout should contain "--segment-speed-file"
And it should exit with an error

Expand All @@ -27,7 +26,6 @@ Feature: osrm-contract command line options: help
And stdout should contain "Configuration:"
And stdout should contain "--threads"
And stdout should contain "--core"
And stdout should contain "--level-cache"
And stdout should contain "--segment-speed-file"
And it should exit successfully

Expand All @@ -42,6 +40,5 @@ Feature: osrm-contract command line options: help
And stdout should contain "Configuration:"
And stdout should contain "--threads"
And stdout should contain "--core"
And stdout should contain "--level-cache"
And stdout should contain "--segment-speed-file"
And it should exit successfully
3 changes: 2 additions & 1 deletion include/contractor/contractor_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct ContractorConfig final : storage::IOConfig
ContractorConfig()
: IOConfig({".osrm.ebg", ".osrm.ebg_nodes", ".osrm.properties"},
{},
{".osrm.level", ".osrm.core", ".osrm.hsgr", ".osrm.enw"}),
{".osrm.hsgr", ".osrm.enw"}),
requested_num_threads(0)
{
}
Expand All @@ -65,6 +65,7 @@ struct ContractorConfig final : storage::IOConfig

unsigned requested_num_threads;

// Deprecated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you add also a release version when it is planed to remove, like // DEPRECATED to be removed in v6.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll open a follow up issue to track removal in v6 too

// A percentage of vertices that will be contracted for the hierarchy.
// Offers a trade-off between preprocessing and query time.
// The remaining vertices form the core of the hierarchy
Expand Down
49 changes: 0 additions & 49 deletions include/contractor/files.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,6 @@ namespace contractor
{
namespace files
{
// reads .osrm.core
template <typename CoreVectorT>
void readCoreMarker(const boost::filesystem::path &path, std::vector<CoreVectorT> &cores)
{
static_assert(util::is_view_or_vector<bool, CoreVectorT>::value,
"cores must be a vector of boolean vectors");
storage::io::FileReader reader(path, storage::io::FileReader::VerifyFingerprint);

auto num_cores = reader.ReadElementCount64();
cores.resize(num_cores);
for (const auto index : util::irange<std::size_t>(0, num_cores))
{
storage::serialization::read(reader, cores[index]);
}
}

// writes .osrm.core
template <typename CoreVectorT>
void writeCoreMarker(const boost::filesystem::path &path, const std::vector<CoreVectorT> &cores)
{
static_assert(util::is_view_or_vector<bool, CoreVectorT>::value,
"cores must be a vector of boolean vectors");
storage::io::FileWriter writer(path, storage::io::FileWriter::GenerateFingerprint);

writer.WriteElementCount64(cores.size());
for (const auto &core : cores)
{
storage::serialization::write(writer, core);
}
}

// reads .osrm.hsgr file
template <typename QueryGraphT, typename EdgeFilterT>
inline void readGraph(const boost::filesystem::path &path,
Expand Down Expand Up @@ -96,24 +65,6 @@ inline void writeGraph(const boost::filesystem::path &path,
storage::serialization::write(writer, filter);
}
}

// reads .levels file
inline void readLevels(const boost::filesystem::path &path, std::vector<float> &node_levels)
{
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
storage::io::FileReader reader{path, fingerprint};

storage::serialization::read(reader, node_levels);
}

// writes .levels file
inline void writeLevels(const boost::filesystem::path &path, const std::vector<float> &node_levels)
{
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
storage::io::FileWriter writer{path, fingerprint};

storage::serialization::write(writer, node_levels);
}
}
}
}
Expand Down
26 changes: 0 additions & 26 deletions include/engine/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ struct Algorithm final
{
};
}
// Contraction Hiearchy with core
namespace corech
{
struct Algorithm final
{
};
}
// Multi-Level Dijkstra
namespace mld
{
Expand All @@ -35,7 +28,6 @@ struct Algorithm final
// Algorithm names
template <typename AlgorithmT> const char *name();
template <> inline const char *name<ch::Algorithm>() { return "CH"; }
template <> inline const char *name<corech::Algorithm>() { return "CoreCH"; }
template <> inline const char *name<mld::Algorithm>() { return "MLD"; }

template <typename AlgorithmT> struct HasAlternativePathSearch final : std::false_type
Expand Down Expand Up @@ -83,24 +75,6 @@ template <> struct HasExcludeFlags<ch::Algorithm> final : std::true_type
{
};

// Algorithms supported by Contraction Hierarchies with core
// the rest is disabled because of performance reasons
template <> struct HasShortestPathSearch<corech::Algorithm> final : std::true_type
{
};
template <> struct HasDirectShortestPathSearch<corech::Algorithm> final : std::true_type
{
};
template <> struct HasMapMatching<corech::Algorithm> final : std::true_type
{
};
template <> struct HasGetTileTurns<corech::Algorithm> final : std::true_type
{
};
template <> struct HasExcludeFlags<corech::Algorithm> final : std::true_type
{
};

// Algorithms supported by Multi-Level Dijkstra
template <> struct HasAlternativePathSearch<mld::Algorithm> final : std::true_type
{
Expand Down
9 changes: 0 additions & 9 deletions include/engine/datafacade/algorithm_datafacade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace datafacade

// Namespace local aliases for algorithms
using CH = routing_algorithms::ch::Algorithm;
using CoreCH = routing_algorithms::corech::Algorithm;
using MLD = routing_algorithms::mld::Algorithm;

template <typename AlgorithmT> class AlgorithmDataFacade;
Expand Down Expand Up @@ -57,14 +56,6 @@ template <> class AlgorithmDataFacade<CH>
const std::function<bool(EdgeData)> filter) const = 0;
};

template <> class AlgorithmDataFacade<CoreCH>
{
public:
using EdgeData = contractor::QueryEdge::EdgeData;

virtual bool IsCoreNode(const NodeID id) const = 0;
};

template <> class AlgorithmDataFacade<MLD>
{
public:
Expand Down
59 changes: 0 additions & 59 deletions include/engine/datafacade/contiguous_internalmem_datafacade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,50 +166,6 @@ class ContiguousInternalMemoryAlgorithmDataFacade<CH> : public datafacade::Algor
}
};

template <>
class ContiguousInternalMemoryAlgorithmDataFacade<CoreCH>
: public datafacade::AlgorithmDataFacade<CoreCH>
{
private:
util::vector_view<bool> m_is_core_node;

// allocator that keeps the allocation data
std::shared_ptr<ContiguousBlockAllocator> allocator;

void InitializeCoreInformationPointer(storage::DataLayout &data_layout,
char *memory_block,
const std::size_t exclude_index)
{
auto core_block_id = static_cast<storage::DataLayout::BlockID>(
storage::DataLayout::CH_CORE_MARKER_0 + exclude_index);
auto core_marker_ptr = data_layout.GetBlockPtr<unsigned>(memory_block, core_block_id);
util::vector_view<bool> is_core_node(core_marker_ptr,
data_layout.num_entries[core_block_id]);
m_is_core_node = std::move(is_core_node);
}

public:
ContiguousInternalMemoryAlgorithmDataFacade(
std::shared_ptr<ContiguousBlockAllocator> allocator_, const std::size_t exclude_index)
: allocator(std::move(allocator_))
{
InitializeInternalPointers(allocator->GetLayout(), allocator->GetMemory(), exclude_index);
}

void InitializeInternalPointers(storage::DataLayout &data_layout,
char *memory_block,
const std::size_t exclude_index)
{
InitializeCoreInformationPointer(data_layout, memory_block, exclude_index);
}

bool IsCoreNode(const NodeID id) const override final
{
BOOST_ASSERT(m_is_core_node.empty() || id < m_is_core_node.size());
return !m_is_core_node.empty() || m_is_core_node[id];
}
};

/**
* This base class implements the Datafacade interface for accessing
* data that's stored in a single large block of memory (RAM).
Expand Down Expand Up @@ -948,21 +904,6 @@ class ContiguousInternalMemoryDataFacade<CH>
}
};

template <>
class ContiguousInternalMemoryDataFacade<CoreCH> final
: public ContiguousInternalMemoryDataFacade<CH>,
public ContiguousInternalMemoryAlgorithmDataFacade<CoreCH>
{
public:
ContiguousInternalMemoryDataFacade(std::shared_ptr<ContiguousBlockAllocator> allocator,
const std::size_t exclude_index)
: ContiguousInternalMemoryDataFacade<CH>(allocator, exclude_index),
ContiguousInternalMemoryAlgorithmDataFacade<CoreCH>(allocator, exclude_index)

{
}
};

template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public AlgorithmDataFacade<MLD>
{
// MLD data
Expand Down
32 changes: 0 additions & 32 deletions include/engine/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,38 +160,6 @@ bool Engine<routing_algorithms::ch::Algorithm>::CheckCompatibility(const EngineC
}
}

template <>
bool Engine<routing_algorithms::corech::Algorithm>::CheckCompatibility(const EngineConfig &config)
{
if (!Engine<routing_algorithms::ch::Algorithm>::CheckCompatibility(config))
{
return false;
}

if (config.use_shared_memory)
{
storage::SharedMonitor<storage::SharedDataTimestamp> barrier;
using mutex_type = typename decltype(barrier)::mutex_type;
boost::interprocess::scoped_lock<mutex_type> current_region_lock(barrier.get_mutex());

auto mem = storage::makeSharedMemory(barrier.data().region);
auto layout = reinterpret_cast<storage::DataLayout *>(mem->Ptr());
return layout->GetBlockSize(storage::DataLayout::CH_CORE_MARKER_0) >
sizeof(std::uint64_t) + sizeof(util::FingerPrint);
}
else
{
if (!boost::filesystem::exists(config.storage_config.GetPath(".osrm.core")))
return false;
storage::io::FileReader in(config.storage_config.GetPath(".osrm.core"),
storage::io::FileReader::VerifyFingerprint);
in.ReadElementCount64(); // number of core markers
const auto number_of_core_markers = in.ReadElementCount64();

return number_of_core_markers > 0;
}
}

template <>
bool Engine<routing_algorithms::mld::Algorithm>::CheckCompatibility(const EngineConfig &config)
{
Expand Down
18 changes: 0 additions & 18 deletions include/engine/routing_algorithms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,6 @@ inline std::vector<routing_algorithms::TurnData> RoutingAlgorithms<Algorithm>::G
return routing_algorithms::getTileTurns(*facade, edges, sorted_edge_indexes);
}

// CoreCH overrides
template <>
InternalManyRoutesResult inline RoutingAlgorithms<
routing_algorithms::corech::Algorithm>::AlternativePathSearch(const PhantomNodes &,
unsigned) const
{
throw util::exception("AlternativePathSearch is disabled due to performance reasons");
}

template <>
inline std::vector<EdgeDuration>
RoutingAlgorithms<routing_algorithms::corech::Algorithm>::ManyToManySearch(
const std::vector<PhantomNode> &,
const std::vector<std::size_t> &,
const std::vector<std::size_t> &) const
{
throw util::exception("ManyToManySearch is disabled due to performance reasons");
}
} // ns engine
} // ns osrm

Expand Down
6 changes: 3 additions & 3 deletions include/engine/routing_algorithms/direct_shortest_path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ namespace engine
namespace routing_algorithms
{

/// This is a striped down version of the general shortest path algorithm.
/// This is a stripped down version of the general shortest path algorithm.
/// The general algorithm always computes two queries for each leg. This is only
/// necessary in case of vias, where the directions of the start node is constrainted
/// necessary in case of vias, where the directions of the start node is constrained
/// by the previous route.
/// This variation is only an optimazation for graphs with slow queries, for example
/// This variation is only an optimization for graphs with slow queries, for example
/// not fully contracted graphs.
template <typename Algorithm>
InternalRouteResult directShortestPathSearch(SearchEngineData<Algorithm> &engine_working_data,
Expand Down
46 changes: 0 additions & 46 deletions include/engine/routing_algorithms/routing_base_ch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,52 +375,6 @@ double getNetworkDistance(SearchEngineData<Algorithm> &engine_working_data,
int duration_upper_bound = INVALID_EDGE_WEIGHT);

} // namespace ch

namespace corech
{
// assumes that heaps are already setup correctly.
// A forced loop might be necessary, if source and target are on the same segment.
// If this is the case and the offsets of the respective direction are larger for the source
// than the target
// then a force loop is required (e.g. source_phantom.forward_segment_id ==
// target_phantom.forward_segment_id
// && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
// requires
// a force loop, if the heaps have been initialized with positive offsets.
void search(SearchEngineData<Algorithm> &engine_working_data,
const DataFacade<corech::Algorithm> &facade,
SearchEngineData<ch::Algorithm>::QueryHeap &forward_heap,
SearchEngineData<ch::Algorithm>::QueryHeap &reverse_heap,
int &weight,
std::vector<NodeID> &packed_leg,
const bool force_loop_forward,
const bool force_loop_reverse,
const PhantomNodes &phantom_nodes,
int duration_upper_bound = INVALID_EDGE_WEIGHT);

// Requires the heaps for be empty
// If heaps should be adjusted to be initialized outside of this function,
// the addition of force_loop parameters might be required
double getNetworkDistance(SearchEngineData<Algorithm> &engine_working_data,
const DataFacade<corech::Algorithm> &facade,
SearchEngineData<ch::Algorithm>::QueryHeap &forward_heap,
SearchEngineData<ch::Algorithm>::QueryHeap &reverse_heap,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
int duration_upper_bound = INVALID_EDGE_WEIGHT);

template <typename RandomIter, typename FacadeT>
void unpackPath(const FacadeT &facade,
RandomIter packed_path_begin,
RandomIter packed_path_end,
const PhantomNodes &phantom_nodes,
std::vector<PathData> &unpacked_path)
{
return ch::unpackPath(facade, packed_path_begin, packed_path_end, phantom_nodes, unpacked_path);
}

} // namespace corech

} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
Expand Down
6 changes: 0 additions & 6 deletions include/engine/search_engine_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ template <> struct SearchEngineData<routing_algorithms::ch::Algorithm>
void InitializeOrClearManyToManyThreadLocalStorage(unsigned number_of_nodes);
};

template <>
struct SearchEngineData<routing_algorithms::corech::Algorithm>
: public SearchEngineData<routing_algorithms::ch::Algorithm>
{
};

struct MultiLayerDijkstraHeapData
{
NodeID parent;
Expand Down
Loading