fixes and refactorings
This commit is contained in:
parent
9e5b79cb34
commit
ead9c0ee2e
7 changed files with 30 additions and 23 deletions
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
@ -11,7 +11,7 @@
|
||||||
"program": "${workspaceFolder}/build/mana_auto_replay",
|
"program": "${workspaceFolder}/build/mana_auto_replay",
|
||||||
"args": [
|
"args": [
|
||||||
"~/Documents/is690-9Li_3H_run094_241020_124254_part001.zip",
|
"~/Documents/is690-9Li_3H_run094_241020_124254_part001.zip",
|
||||||
"--plugin=src/libmana-plugin-c-test.so"
|
"--plugin=src/libmana-plugin-root-histogram.so"
|
||||||
],
|
],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}/build",
|
"cwd": "${workspaceFolder}/build",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef C536E080_25D7_476D_B8E3_25912B9CFC3B
|
#ifndef C536E080_25D7_476D_B8E3_25912B9CFC3B
|
||||||
#define C536E080_25D7_476D_B8E3_25912B9CFC3B
|
#define C536E080_25D7_476D_B8E3_25912B9CFC3B
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
@ -21,6 +22,6 @@ inline double make_quiet_nan()
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace mesytec::mnode
|
||||||
|
|
||||||
#endif /* C536E080_25D7_476D_B8E3_25912B9CFC3B */
|
#endif /* C536E080_25D7_476D_B8E3_25912B9CFC3B */
|
||||||
|
|
|
@ -17,7 +17,7 @@ if (MNODE_BUILD_TESTS)
|
||||||
function (add_mnode_gtest name)
|
function (add_mnode_gtest name)
|
||||||
add_executable(test_${name} ${name}.test.cc)
|
add_executable(test_${name} ${name}.test.cc)
|
||||||
target_link_libraries(test_${name} PRIVATE mesytec-mnode GTest::gtest_main spdlog)
|
target_link_libraries(test_${name} PRIVATE mesytec-mnode GTest::gtest_main spdlog)
|
||||||
add_test(NAME name COMMAND $<TARGET_FILE:test_${name}>)
|
add_test(NAME test_${name} COMMAND $<TARGET_FILE:test_${name}>)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
add_mnode_gtest(mana)
|
add_mnode_gtest(mana)
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <mesytec-mnode/mnode_cpp_types.h>
|
||||||
#include <mesytec-mnode/mnode_math.h>
|
#include <mesytec-mnode/mnode_math.h>
|
||||||
#include <mesytec-mvlc/util/fmt.h>
|
#include <mesytec-mvlc/util/fmt.h>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace mesytec::mnode::mana
|
namespace mesytec::mnode::mana
|
||||||
{
|
{
|
||||||
|
@ -15,7 +17,7 @@ class Arena
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr size_t initial_segment_size = 1u << 20;
|
static constexpr size_t initial_segment_size = 1u << 20;
|
||||||
static constexpr size_t default_pad = 8;
|
static constexpr size_t default_align_to = 8;
|
||||||
static constexpr size_t default_max_segments = 1;
|
static constexpr size_t default_max_segments = 1;
|
||||||
|
|
||||||
Arena() = default;
|
Arena() = default;
|
||||||
|
@ -25,11 +27,11 @@ class Arena
|
||||||
Arena &operator=(Arena &&other) = default;
|
Arena &operator=(Arena &&other) = default;
|
||||||
|
|
||||||
// pushes at least the required amount of memory onto the arena.
|
// pushes at least the required amount of memory onto the arena.
|
||||||
// 'required' is rounded up to the nearest multiple of 'default_pad' to make
|
// 'required' is rounded up to the nearest multiple of 'default_align_to' to make
|
||||||
// subsequent allocations aligned.
|
// subsequent allocations aligned.
|
||||||
u8 *push_size(size_t required)
|
u8 *push_size(size_t required)
|
||||||
{
|
{
|
||||||
size_t padded = round_up(required, default_pad);
|
size_t padded = round_up(required, default_align_to);
|
||||||
size_t pad_waste = padded - required;
|
size_t pad_waste = padded - required;
|
||||||
required = padded;
|
required = padded;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
#include "internal/mana_arena.h"
|
||||||
|
#include "internal/mana_lib.hpp"
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <mesytec-mnode/mnode_cpp_types.h>
|
#include <mesytec-mnode/mnode_cpp_types.h>
|
||||||
#include "internal/mana_arena.h"
|
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include "internal/mana_lib.hpp"
|
|
||||||
|
|
||||||
using namespace mesytec::mnode;
|
using namespace mesytec::mnode;
|
||||||
|
|
||||||
|
@ -18,35 +18,35 @@ TEST(mnode_mana_arena, push_reset_push)
|
||||||
|
|
||||||
for (size_t i = 0; i < 10; ++i)
|
for (size_t i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
auto mem = arena.push_size(mana::Arena::default_pad + 2);
|
auto mem = arena.push_size(mana::Arena::default_align_to + 2);
|
||||||
ASSERT_NE(mem, nullptr);
|
ASSERT_NE(mem, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_EQ(arena.allocations(), 10);
|
ASSERT_EQ(arena.allocations(), 10);
|
||||||
ASSERT_GE(arena.pad_waste(), 0);
|
ASSERT_GE(arena.pad_waste(), 0);
|
||||||
ASSERT_GE(arena.segment_count(), 1);
|
ASSERT_GE(arena.segment_count(), 1);
|
||||||
ASSERT_GE(arena.capacity(), 10 * (mana::Arena::default_pad + 2));
|
ASSERT_GE(arena.capacity(), 10 * (mana::Arena::default_align_to + 2));
|
||||||
ASSERT_EQ(arena.used(), 10 * (mana::Arena::default_pad + 2));
|
ASSERT_EQ(arena.used(), 10 * (mana::Arena::default_align_to + 2));
|
||||||
|
|
||||||
arena.reset();
|
arena.reset();
|
||||||
|
|
||||||
ASSERT_EQ(arena.allocations(), 0);
|
ASSERT_EQ(arena.allocations(), 0);
|
||||||
ASSERT_EQ(arena.pad_waste(), 0);
|
ASSERT_EQ(arena.pad_waste(), 0);
|
||||||
ASSERT_GE(arena.segment_count(), 1);
|
ASSERT_GE(arena.segment_count(), 1);
|
||||||
ASSERT_GE(arena.capacity(), 10 * (mana::Arena::default_pad + 2));
|
ASSERT_GE(arena.capacity(), 10 * (mana::Arena::default_align_to + 2));
|
||||||
ASSERT_EQ(arena.used(), 0);
|
ASSERT_EQ(arena.used(), 0);
|
||||||
|
|
||||||
for (size_t i = 0; i < 10; ++i)
|
for (size_t i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
auto mem = arena.push_size(mana::Arena::default_pad + 2);
|
auto mem = arena.push_size(mana::Arena::default_align_to + 2);
|
||||||
ASSERT_NE(mem, nullptr);
|
ASSERT_NE(mem, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_EQ(arena.allocations(), 10);
|
ASSERT_EQ(arena.allocations(), 10);
|
||||||
ASSERT_GE(arena.pad_waste(), 0);
|
ASSERT_GE(arena.pad_waste(), 0);
|
||||||
ASSERT_GE(arena.segment_count(), 1);
|
ASSERT_GE(arena.segment_count(), 1);
|
||||||
ASSERT_GE(arena.capacity(), 10 * (mana::Arena::default_pad + 2));
|
ASSERT_GE(arena.capacity(), 10 * (mana::Arena::default_align_to + 2));
|
||||||
ASSERT_EQ(arena.used(), 10 * (mana::Arena::default_pad + 2));
|
ASSERT_EQ(arena.used(), 10 * (mana::Arena::default_align_to + 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(mnode_mana_offset_ptr, basic)
|
TEST(mnode_mana_offset_ptr, basic)
|
||||||
|
@ -93,8 +93,8 @@ TEST(mnode_mana_offset_ptr, strings)
|
||||||
auto s0 = arena.push_cstr("hello");
|
auto s0 = arena.push_cstr("hello");
|
||||||
auto s1 = arena.push_cstr("world");
|
auto s1 = arena.push_cstr("world");
|
||||||
|
|
||||||
spdlog::info("&t->ptr0={}, &t->ptr1={}", fmt::ptr(&t->ptr0), fmt::ptr(&t->ptr1));
|
// spdlog::info("&t->ptr0={}, &t->ptr1={}", fmt::ptr(&t->ptr0), fmt::ptr(&t->ptr1));
|
||||||
spdlog::info("s0={} @ {}, s1={} @ {}", s0, fmt::ptr(s0), s1, fmt::ptr(s1));
|
// spdlog::info("s0={} @ {}, s1={} @ {}", s0, fmt::ptr(s0), s1, fmt::ptr(s1));
|
||||||
|
|
||||||
set(t->ptr0, s0);
|
set(t->ptr0, s0);
|
||||||
set(t->ptr1, s1);
|
set(t->ptr1, s1);
|
||||||
|
|
|
@ -13,6 +13,8 @@ namespace py = pybind11;
|
||||||
|
|
||||||
PYBIND11_EMBEDDED_MODULE(py_mana, m) {}
|
PYBIND11_EMBEDDED_MODULE(py_mana, m) {}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
struct Context
|
struct Context
|
||||||
{
|
{
|
||||||
py::scoped_interpreter interp;
|
py::scoped_interpreter interp;
|
||||||
|
@ -23,6 +25,7 @@ struct Context
|
||||||
py::object py_end_run;
|
py::object py_end_run;
|
||||||
std::vector<std::vector<py::object>> eventBuffers;
|
std::vector<std::vector<py::object>> eventBuffers;
|
||||||
};
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
MANA_DEFINE_PLUGIN_INIT(init)
|
MANA_DEFINE_PLUGIN_INIT(init)
|
||||||
{
|
{
|
||||||
|
|
|
@ -295,8 +295,9 @@ struct NngPairStrategy: public ProcessingStrategy
|
||||||
auto s = sw.get_elapsed().count() / (1000.0 * 1000.0);
|
auto s = sw.get_elapsed().count() / (1000.0 * 1000.0);
|
||||||
auto bytesPerSecond = totalBytesProcessed / s;
|
auto bytesPerSecond = totalBytesProcessed / s;
|
||||||
auto MiBPerSecond = bytesPerSecond / (1u << 20);
|
auto MiBPerSecond = bytesPerSecond / (1u << 20);
|
||||||
std::cout << fmt::format("Processed {} buffers, {} bytes. t={} s, rate={} MiB/s\n",
|
std::cout << fmt::format(
|
||||||
bufferNumber, totalBytesProcessed, s, MiBPerSecond);
|
"Processed {} buffers, {} bytes. t={} s, rate={:.2f} MiB/s\n", bufferNumber,
|
||||||
|
totalBytesProcessed, s, MiBPerSecond);
|
||||||
}(sw, bufferNumber, totalBytesProcessed);
|
}(sw, bufferNumber, totalBytesProcessed);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -343,9 +344,9 @@ struct NngPairStrategy: public ProcessingStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
report();
|
report();
|
||||||
spdlog::info("NngPairStrategy: producerTx: {} MiB, {} messages",
|
spdlog::debug("NngPairStrategy: producerTx: {:.2f} MiB, {} messages",
|
||||||
producerTx.bytes / (1024.0 * 1024), producerTx.messages);
|
producerTx.bytes / (1024.0 * 1024), producerTx.messages);
|
||||||
spdlog::info("NngPairStrategy: consumerRx: {} MiB, {} messages",
|
spdlog::debug("NngPairStrategy: consumerRx: {:.2f} MiB, {} messages",
|
||||||
consumerRx.bytes / (1024.0 * 1024), consumerRx.messages);
|
consumerRx.bytes / (1024.0 * 1024), consumerRx.messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue