1212
1313#include < boost/assert.hpp>
1414
15+ #include < cstddef>
1516#include < tbb/blocked_range.h>
1617#include < tbb/enumerable_thread_specific.h>
1718#include < tbb/parallel_for.h>
@@ -33,6 +34,8 @@ struct ContractorThreadData
3334 std::vector<ContractorEdge> inserted_edges;
3435 std::vector<NodeID> neighbours;
3536 explicit ContractorThreadData (NodeID nodes) : heap(nodes) {}
37+ /* * Code instrumentation: the max. occupancy of the heap */
38+ std::size_t max_heap_occupancy{0 };
3639};
3740
3841struct ContractorNodeData
@@ -98,21 +101,19 @@ struct RemainingNodeData
98101
99102struct ThreadDataContainer
100103{
101- explicit ThreadDataContainer (int number_of_nodes) : number_of_nodes(number_of_nodes ) {}
104+ explicit ThreadDataContainer () {}
102105
103106 inline ContractorThreadData *GetThreadData ()
104107 {
105108 bool exists = false ;
106109 auto &ref = data.local (exists);
107110 if (!exists)
108111 {
109- ref = std::make_shared<ContractorThreadData>(number_of_nodes );
112+ ref = std::make_shared<ContractorThreadData>(HASH_MAP_CAPACITY );
110113 }
111114
112115 return ref.get ();
113116 }
114-
115- int number_of_nodes;
116117 using EnumerableThreadData =
117118 tbb::enumerable_thread_specific<std::shared_ptr<ContractorThreadData>>;
118119 EnumerableThreadData data;
@@ -230,7 +231,6 @@ void ContractNode(ContractorThreadData *data,
230231
231232 if (RUNSIMULATION)
232233 {
233- const int constexpr SIMULATION_SEARCH_SPACE_SIZE = 1000 ;
234234 search (heap,
235235 graph,
236236 contractable,
@@ -241,7 +241,6 @@ void ContractNode(ContractorThreadData *data,
241241 }
242242 else
243243 {
244- const int constexpr FULL_SEARCH_SPACE_SIZE = 2000 ;
245244 search (heap,
246245 graph,
247246 contractable,
@@ -298,6 +297,7 @@ void ContractNode(ContractorThreadData *data,
298297 }
299298 }
300299 }
300+ data->max_heap_occupancy = std::max (heap.Occupancy (), data->max_heap_occupancy );
301301 }
302302
303303 // Check For One-Way Streets to decide on the creation of self-loops
@@ -567,7 +567,7 @@ std::vector<bool> contractGraph(ContractorGraph &graph,
567567
568568 const NodeID number_of_nodes = graph.GetNumberOfNodes ();
569569
570- ThreadDataContainer thread_data_list (number_of_nodes) ;
570+ ThreadDataContainer thread_data_list;
571571
572572 NodeID number_of_contracted_nodes = 0 ;
573573 std::vector<NodeID> new_to_old_node_id (number_of_nodes);
@@ -757,6 +757,18 @@ std::vector<bool> contractGraph(ContractorGraph &graph,
757757 node_data.Renumber (new_to_old_node_id);
758758 RenumberGraph (graph, new_to_old_node_id);
759759
760+ std::size_t max_heap_occupancy = 0 ;
761+ for (auto &data : thread_data_list.data .range ())
762+ {
763+ max_heap_occupancy = std::max (max_heap_occupancy, data->max_heap_occupancy );
764+ }
765+ util::Log (logDEBUG) << " Max. heap occupancy = " << max_heap_occupancy;
766+ if (max_heap_occupancy >= RELAXED_NODE_LIMIT)
767+ {
768+ util::Log (logWARNING) << " Heap size insufficient. Please increase HASH_MAP_CAPACITY and "
769+ " recompile and/or open an issue on github." ;
770+ }
771+
760772 return std::move (node_data.is_core );
761773}
762774
0 commit comments