From f5cb3570b8541c24e87365de3f8a862ebf7351b8 Mon Sep 17 00:00:00 2001 From: mrks Date: Tue, 5 May 2020 15:02:31 +0200 Subject: [PATCH] Remove NumaMemoryResource (#2114) Removes dead code, fixes #2087 --- .gitmodules | 3 -- CMakeLists.txt | 2 +- src/CMakeLists.txt | 5 -- src/lib/CMakeLists.txt | 4 +- src/lib/memory/numa_memory_resource.cpp | 51 ------------------- src/lib/memory/numa_memory_resource.hpp | 35 ------------- src/lib/scheduler/topology.cpp | 25 --------- src/lib/scheduler/topology.hpp | 14 ----- src/test/CMakeLists.txt | 1 - src/test/memory/numa_memory_resource_test.cpp | 42 --------------- third_party/CMakeLists.txt | 9 ---- third_party/pgasus | 1 - 12 files changed, 2 insertions(+), 190 deletions(-) delete mode 100644 src/lib/memory/numa_memory_resource.cpp delete mode 100644 src/lib/memory/numa_memory_resource.hpp delete mode 100644 src/test/memory/numa_memory_resource_test.cpp delete mode 160000 third_party/pgasus diff --git a/.gitmodules b/.gitmodules index e93e28d967..39a5838c03 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,9 +37,6 @@ [submodule "third_party/nlohmann_json"] path = third_party/nlohmann_json url = https://github.com/nlohmann/json.git -[submodule "third_party/pgasus"] - path = third_party/pgasus - url = https://github.com/hyrise/pgasus.git [submodule "third_party/sql-parser"] path = third_party/sql-parser url = https://github.com/hyrise/sql-parser diff --git a/CMakeLists.txt b/CMakeLists.txt index cf3dd4a2a6..b9a228e7f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,7 +146,7 @@ endif() add_subdirectory(third_party/ EXCLUDE_FROM_ALL) # Some third-party libs don't support LTO (if enabled above): -foreach(no_lto_target gtest gtest_main gmock gmock_main hpinuma_s hpinuma hpinuma_base_s hpinuma_base hpinuma_util_tool hpinuma_msource hpinuma_msource_s) +foreach(no_lto_target gtest gtest_main gmock gmock_main) if(TARGET no_lto_target) set_property(TARGET ${no_lto_target} PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 708b6c962f..21e13d31e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -86,11 +86,6 @@ include_directories( ${PROJECT_SOURCE_DIR}/third_party/tpcds-result-reproduction ) -if (${ENABLE_NUMA_SUPPORT}) - include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/third_party/pgasus/include) - include_directories(SYSTEM ${PROJECT_BINARY_DIR}/third_party/pgasus/src) -endif() - set(ENABLE_CLANG_TIDY OFF CACHE BOOL "Run clang-tidy") if (ENABLE_CLANG_TIDY) message(STATUS "clang-tidy enabled") diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 5d4eb9b38c..ff979f70e1 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -166,8 +166,6 @@ set( logical_query_plan/validate_node.cpp logical_query_plan/validate_node.hpp memory/boost_default_memory_resource.cpp - memory/numa_memory_resource.cpp - memory/numa_memory_resource.hpp lossless_cast.cpp lossless_cast.hpp null_value.hpp @@ -656,7 +654,7 @@ if (NOT APPLE) endif() if (${ENABLE_NUMA_SUPPORT}) - set(LIBRARIES ${LIBRARIES} ${NUMA_LIBRARY} hpinuma_msource_s) + set(LIBRARIES ${LIBRARIES} ${NUMA_LIBRARY}) endif() set(ERASE_SEGMENT_TYPES "" CACHE STRING "Erase iterators and accessors for these types (e.g., RunLength,FrameOfReference). Good for compile time, bad for run time (if these types end up being used)") diff --git a/src/lib/memory/numa_memory_resource.cpp b/src/lib/memory/numa_memory_resource.cpp deleted file mode 100644 index 4816eb7b69..0000000000 --- a/src/lib/memory/numa_memory_resource.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "numa_memory_resource.hpp" - -#include - -#if HYRISE_NUMA_SUPPORT -constexpr auto NUMA_MEMORY_RESOURCE_ARENA_SIZE = 1024llu * 1024 * 1024; -#else -#include -#endif - -namespace opossum { - -#if HYRISE_NUMA_SUPPORT -NUMAMemoryResource::NUMAMemoryResource(int node_id, const std::string& name) - : _memory_source(numa::MemSource::create(node_id, NUMA_MEMORY_RESOURCE_ARENA_SIZE, name.c_str())) {} - -void* NUMAMemoryResource::do_allocate(std::size_t bytes, std::size_t alignment) { - return _memory_source.allocAligned(boost::integer::lcm(_alignment, alignment), bytes); -} - -void NUMAMemoryResource::do_deallocate(void* p, std::size_t bytes, std::size_t alignment) { numa::MemSource::free(p); } - -bool NUMAMemoryResource::do_is_equal(const memory_resource& other) const noexcept { - const auto other_numa_resource = dynamic_cast(&other); - if (!other_numa_resource) { - return false; - } else { - return other_numa_resource->_memory_source == _memory_source; - } -} - -int NUMAMemoryResource::get_node_id() const { return _memory_source.getPhysicalNode(); } - -#else - -NUMAMemoryResource::NUMAMemoryResource(int node_id, const std::string& name) {} - -void* NUMAMemoryResource::do_allocate(std::size_t bytes, std::size_t alignment) { - return boost::container::pmr::get_default_resource()->allocate(bytes, alignment); -} - -void NUMAMemoryResource::do_deallocate(void* p, std::size_t bytes, std::size_t alignment) { - boost::container::pmr::get_default_resource()->deallocate(p, bytes, alignment); -} - -bool NUMAMemoryResource::do_is_equal(const memory_resource& other) const noexcept { return true; } - -int NUMAMemoryResource::get_node_id() const { return UNDEFINED_NODE_ID; } -#endif - -} // namespace opossum diff --git a/src/lib/memory/numa_memory_resource.hpp b/src/lib/memory/numa_memory_resource.hpp deleted file mode 100644 index 56c6118d4b..0000000000 --- a/src/lib/memory/numa_memory_resource.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include - -#include -#include - -#if HYRISE_NUMA_SUPPORT -#include -#endif - -namespace opossum { - -class NUMAMemoryResource : public boost::container::pmr::memory_resource { - public: - NUMAMemoryResource(int node_id, const std::string& name); - - virtual void* do_allocate(std::size_t bytes, std::size_t alignment); - - virtual void do_deallocate(void* p, std::size_t bytes, std::size_t alignment); - - virtual bool do_is_equal(const memory_resource& other) const noexcept; - - int get_node_id() const; - - static constexpr int UNDEFINED_NODE_ID = -1; - - private: -#if HYRISE_NUMA_SUPPORT - const numa::MemSource _memory_source; - const size_t _alignment = 1; -#endif -}; - -} // namespace opossum diff --git a/src/lib/scheduler/topology.cpp b/src/lib/scheduler/topology.cpp index 3d1d230284..e526dbff63 100644 --- a/src/lib/scheduler/topology.cpp +++ b/src/lib/scheduler/topology.cpp @@ -14,8 +14,6 @@ #include #include -#include "memory/numa_memory_resource.hpp" - namespace opossum { #if HYRISE_NUMA_SUPPORT @@ -104,8 +102,6 @@ void Topology::_init_numa_topology(uint32_t max_num_cores) { } } - _create_memory_resources(); - numa_free_cpumask(affinity_cpu_bitmask); numa_free_cpumask(this_node_cpu_bitmask); #endif @@ -128,8 +124,6 @@ void Topology::_init_non_numa_topology(uint32_t max_num_cores) { auto node = TopologyNode(std::move(cpus)); _nodes.emplace_back(std::move(node)); - - _create_memory_resources(); } void Topology::_init_fake_numa_topology(uint32_t max_num_workers, uint32_t workers_per_node) { @@ -162,36 +156,17 @@ void Topology::_init_fake_numa_topology(uint32_t max_num_workers, uint32_t worke } _num_cpus = num_workers; - _create_memory_resources(); } const std::vector& Topology::nodes() const { return _nodes; } size_t Topology::num_cpus() const { return _num_cpus; } -boost::container::pmr::memory_resource* Topology::get_memory_resource(int node_id) { - DebugAssert(node_id >= 0 && node_id < static_cast(_nodes.size()), "node_id is out of bounds"); - return &_memory_resources[static_cast(node_id)]; -} - void Topology::_clear() { _nodes.clear(); - _memory_resources.clear(); _num_cpus = 0; } -void Topology::_create_memory_resources() { - for (auto node_id = int{0}; node_id < static_cast(_nodes.size()); ++node_id) { - auto memsource_name = std::stringstream(); - memsource_name << "numa_" << std::setw(3) << std::setfill('0') << node_id; - - // If we have a fake NUMA topology that has more nodes than our system has available, - // distribute the fake nodes among the physically available ones. - auto system_node_id = _fake_numa_topology ? node_id % _number_of_hardware_nodes : node_id; - _memory_resources.emplace_back(NUMAMemoryResource(system_node_id, memsource_name.str())); - } -} - std::ostream& operator<<(std::ostream& stream, const Topology& topology) { stream << "Number of CPUs: " << topology.num_cpus() << std::endl; if (topology._filtered_by_affinity) { diff --git a/src/lib/scheduler/topology.hpp b/src/lib/scheduler/topology.hpp index 8980f6c994..444c7f4e49 100644 --- a/src/lib/scheduler/topology.hpp +++ b/src/lib/scheduler/topology.hpp @@ -5,17 +5,8 @@ #include #include -#include "memory/numa_memory_resource.hpp" #include "types.hpp" -namespace boost { -namespace container { -namespace pmr { -class memory_resource; -} -} // namespace container -} // namespace boost - namespace opossum { struct TopologyCpu final { @@ -82,8 +73,6 @@ class Topology final : public Noncopyable { size_t num_cpus() const; - boost::container::pmr::memory_resource* get_memory_resource(int node_id); - private: Topology(); @@ -96,7 +85,6 @@ class Topology final : public Noncopyable { void _init_fake_numa_topology(uint32_t max_num_workers = 0, uint32_t workers_per_node = 1); void _clear(); - void _create_memory_resources(); std::vector _nodes; uint32_t _num_cpus{0}; @@ -104,8 +92,6 @@ class Topology final : public Noncopyable { bool _filtered_by_affinity{false}; static const int _number_of_hardware_nodes; - - std::vector _memory_resources; }; std::ostream& operator<<(std::ostream& stream, const Topology& topology); diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 781f9ee6cf..084ae3f044 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -74,7 +74,6 @@ set( logical_query_plan/validate_node_test.cpp lossless_cast_test.cpp memory/segments_using_allocators_test.cpp - memory/numa_memory_resource_test.cpp operators/aggregate_test.cpp operators/alias_operator_test.cpp operators/change_meta_table_test.cpp diff --git a/src/test/memory/numa_memory_resource_test.cpp b/src/test/memory/numa_memory_resource_test.cpp deleted file mode 100644 index e3d9c4a887..0000000000 --- a/src/test/memory/numa_memory_resource_test.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include - -#include "base_test.hpp" - -#if HYRISE_NUMA_SUPPORT -#include -#endif - -#include "memory/numa_memory_resource.hpp" -#include "types.hpp" - -namespace opossum { - -int get_node_id_of(const void* ptr) { -#if HYRISE_NUMA_SUPPORT - int status[1]; - void* addr = {const_cast(ptr)}; - numa_move_pages(0, 1, static_cast(&addr), nullptr, reinterpret_cast(&status), 0); - return status[0]; -#else - return 1; -#endif -} - -class NUMAMemoryResourceTest : public BaseTest {}; - -TEST_F(NUMAMemoryResourceTest, BasicAllocate) { -#if HYRISE_NUMA_SUPPORT - const int numa_node = numa_max_node(); -#else - const int numa_node = 1; -#endif - - auto memory_resource = NUMAMemoryResource(numa_node, "test"); - const auto alloc = PolymorphicAllocator(&memory_resource); - - const auto vec = pmr_vector(1024, alloc); - - EXPECT_EQ(get_node_id_of(vec.data()), numa_node); -} - -} // namespace opossum diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index efc7753c13..2efef74688 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -99,15 +99,6 @@ add_subdirectory(libpqxx) add_subdirectory(tpch-dbgen) add_subdirectory(nlohmann_json) -# Add PGASUS -if(${NUMA_FOUND}) - set(PGASUS_WITH_TASKING OFF CACHE BOOL "" FORCE) - set(PGASUS_REPLACE_MALLOC OFF CACHE BOOL "" FORCE) - set(PGASUS_BUILD_TESTS OFF CACHE BOOL "" FORCE) - set(PGASUS_BUILD_DOCUMENTATION OFF CACHE BOOL "" FORCE) - add_subdirectory(pgasus) -endif() - ## Build lz4 set(LZ4_LIBRARY_DIR lz4/lib) diff --git a/third_party/pgasus b/third_party/pgasus deleted file mode 160000 index 159260d52d..0000000000 --- a/third_party/pgasus +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 159260d52d05d777df85a57f80c983afb4714515