From 0c7de54be756edcd5615e38aff5b1bb67d1aa113 Mon Sep 17 00:00:00 2001 From: peterlau123 Date: Wed, 26 Nov 2025 21:45:51 +0800 Subject: [PATCH 01/10] fix: fix C4251 as error in windows --- include/NovaLLM/data/tensor.h | 13 ++++++++++++- include/NovaLLM/memory/buffer_hub.h | 17 ++++++++++++++--- include/NovaLLM/memory/buffer_manager.h | 8 ++++++++ source/memory/buffer_manager.cpp | 3 ++- test/source/buffer_hub_test.cpp | 4 ++-- 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/include/NovaLLM/data/tensor.h b/include/NovaLLM/data/tensor.h index a31539c..6efdf0f 100644 --- a/include/NovaLLM/data/tensor.h +++ b/include/NovaLLM/data/tensor.h @@ -1,4 +1,11 @@ #pragma once + +// Disable C4251 warning on Windows (DLL interface for STL containers) +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4251) +#endif + #include #include #include @@ -152,4 +159,8 @@ class NOVA_LLM_API Tensor { Deleter m_deleter_ = DefaultDeletor(); ///< 自定义删除器 }; -} // namespace nova_llm \ No newline at end of file +} // namespace nova_llm + +#ifdef _MSC_VER +#pragma warning(pop) +#endif diff --git a/include/NovaLLM/memory/buffer_hub.h b/include/NovaLLM/memory/buffer_hub.h index 2be8820..2d0a113 100644 --- a/include/NovaLLM/memory/buffer_hub.h +++ b/include/NovaLLM/memory/buffer_hub.h @@ -1,4 +1,11 @@ #pragma once + +// Disable C4251 warning on Windows (DLL interface for STL containers) +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4251) +#endif + #include #include #include @@ -66,7 +73,7 @@ class LevelAssignStrategy { class BufferHubConfig { public: - BufferHubConfig(DeviceType device_type, IAllocatorSharedPtr allocator, Size size_limit=Size(4UL*1024*1024*1024), LevelAssignStrategy strategy = LevelAssignStrategy(), float warning_level = 0.95) + BufferHubConfig(DeviceType device_type, IAllocatorSharedPtr allocator, Size size_limit=Size(4UL*1024*1024*1024), LevelAssignStrategy strategy = LevelAssignStrategy(), float warning_level = 0.95f) : device_type_(device_type), size_limit_(size_limit), warning_level_(warning_level), @@ -128,7 +135,7 @@ class BufferHubLevel { private: void refill(const Size& sz); - uint32_t index_ = -1; // level index in buffer hub + uint32_t index_ = static_cast(-1); // level index in buffer hub Size block_size_ {static_cast(0)}; // each block size at this level uint32_t expand_factor_ = 2; @@ -209,10 +216,14 @@ class NOVA_LLM_API BufferHub { Size size_limit_; // Memory in buffer hub cannot exceed this limit - float warning_level_ = 0.95; // Be cautious when memory in buffer hub exceeds size_limit*warning_level + float warning_level_ = 0.95f; // Be cautious when memory in buffer hub exceeds size_limit*warning_level IAllocatorSharedPtr allocator_; }; } // namespace nova_llm + +#ifdef _MSC_VER +#pragma warning(pop) +#endif diff --git a/include/NovaLLM/memory/buffer_manager.h b/include/NovaLLM/memory/buffer_manager.h index 54702ff..8e19e41 100644 --- a/include/NovaLLM/memory/buffer_manager.h +++ b/include/NovaLLM/memory/buffer_manager.h @@ -8,6 +8,10 @@ #include "NovaLLM/memory/allocator.h" #include "NovaLLM/memory/buffer_define.h" #include "NovaLLM/memory/buffer_hub.h" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4251) +#endif namespace nova_llm { /* @@ -77,3 +81,7 @@ class NOVA_LLM_API BufferManager { }; } // namespace nova_llm + +#ifdef _MSC_VER +#pragma warning(pop) +#endif \ No newline at end of file diff --git a/source/memory/buffer_manager.cpp b/source/memory/buffer_manager.cpp index b97ff25..7790c74 100644 --- a/source/memory/buffer_manager.cpp +++ b/source/memory/buffer_manager.cpp @@ -4,6 +4,7 @@ #include "NovaLLM/memory/buffer_hub.h" #include "NovaLLM/utils/log.h" #include "NovaLLM/utils/macros.h" +// Disable C4251 warning on Windows (DLL interface for STL containers) namespace nova_llm { @@ -68,4 +69,4 @@ void BufferManager::destroy() { } -} // namespace nova_llm +} // namespace nova_llm \ No newline at end of file diff --git a/test/source/buffer_hub_test.cpp b/test/source/buffer_hub_test.cpp index b094a07..68de60d 100644 --- a/test/source/buffer_hub_test.cpp +++ b/test/source/buffer_hub_test.cpp @@ -89,7 +89,7 @@ TEST_F(CPUBufferHubTest, ConcurrentAddSizeLevel) { // Each thread adds multiple size levels for (int t = 0; t < num_threads; ++t) { - threads.emplace_back([this, t, &success_count,&num_levels_per_thread]() { + threads.emplace_back([this, t, &success_count]() { for (int i = 0; i < num_levels_per_thread; ++i) { // Create unique sizes for each thread to avoid conflicts uint64_t size_bytes = (1 << 20) * (t * num_levels_per_thread + i + 100); // 100MB+ @@ -153,7 +153,7 @@ TEST_F(CPUBufferHubTest, ConcurrentGetBlock) { // Multiple threads requesting blocks of the same size concurrently for (int t = 0; t < num_threads; ++t) { - threads.emplace_back([this, t, &thread_blocks, &successful_gets,&blocks_per_thread]() { + threads.emplace_back([this, t, &thread_blocks, &successful_gets]() { for (int i = 0; i < blocks_per_thread; ++i) { auto* block = getBufferHub()->getBlock(Size(4096)); // 4KB blocks if (block != nullptr && block->data != nullptr) { From 53663fb73ea7c672c8a431c07d88255cd100c836 Mon Sep 17 00:00:00 2001 From: peterlau123 Date: Wed, 26 Nov 2025 22:04:03 +0800 Subject: [PATCH 02/10] fix : fix capture error in windows --- test/source/buffer_hub_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/source/buffer_hub_test.cpp b/test/source/buffer_hub_test.cpp index 68de60d..e5af107 100644 --- a/test/source/buffer_hub_test.cpp +++ b/test/source/buffer_hub_test.cpp @@ -82,8 +82,8 @@ TEST_F(CPUBufferHubTest, PutBlockFromBuffer) { // Concurrent access tests TEST_F(CPUBufferHubTest, ConcurrentAddSizeLevel) { - const int num_threads = 10; - const int num_levels_per_thread = 5; + constexpr int num_threads = 10; + constexpr int num_levels_per_thread = 5; std::vector threads; std::atomic success_count {0}; @@ -145,8 +145,8 @@ TEST_F(CPUBufferHubTest, ConcurrentEraseSizeLevel) { } TEST_F(CPUBufferHubTest, ConcurrentGetBlock) { - const int num_threads = 20; - const int blocks_per_thread = 5; + constexpr int num_threads = 20; + constexpr int blocks_per_thread = 5; std::vector threads; std::vector> thread_blocks(num_threads); std::atomic successful_gets {0}; From e9d71c6633b40067bb9857e491e9d582bec9eafc Mon Sep 17 00:00:00 2001 From: peterlau123 Date: Wed, 26 Nov 2025 22:16:17 +0800 Subject: [PATCH 03/10] fix: fix ubuntu code coverage error --- .github/workflows/ubuntu.yml | 57 ++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index f935990..849b362 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -159,15 +159,60 @@ jobs: -DENABLE_TEST_COVERAGE=ON \ -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" cmake --build . --config Debug - ctest --output-on-failure || true + + # Create empty coverage files to ensure they exist + find . -name "*.gcda" -exec rm {} \; 2>/dev/null || true + find . -name "*.gcno" -exec touch {} \; 2>/dev/null || true + + # Run tests one by one to ensure proper execution and output + echo "Running tests individually..." + for test_file in $(find . -name "NovaLLMTests*" -type f -executable); do + echo "Running $test_file..." + $test_file --gtest_output=xml:test_results.xml --gtest_filter="*Concurrent*" || ( + echo "Test $test_file completed with issues, checking for coverage data..." + ) + done + + # Explicitly run ctest + ctest --output-on-failure --verbose || echo "ctest failed, proceeding to coverage..." - name: Generate coverage report run: | cd build-coverage - # lcov --directory . --capture --output-file coverage.info - # Added --ignore-errors mismatch to handle GTest/GCC 13 issues - lcov --directory . --capture --output-file coverage.info --ignore-errors mismatch - lcov --remove coverage.info '/usr/*' '*/test/*' '*/conan/*' --output-file coverage.info - lcov --list coverage.info + echo "Checking for .gcda files..." + find . -name "*.gcda" -type f | head -10 + + # Capture coverage data with better error handling + echo "Capturing coverage data..." + lcov --directory . \ + --capture \ + --output-file coverage.info \ + --ignore-errors mismatch,gcov,unused \ + --no-external \ + --base-directory $GITHUB_WORKSPACE || echo "lcov capture had issues, proceeding..." + + # Check if coverage.info was created and has content + if [ -f coverage.info ]; then + echo "Coverage file created, size: $(du -h coverage.info)" + cat coverage.info | head -20 + + # Remove unwanted paths + echo "Removing unwanted paths..." + lcov --remove coverage.info \ + '/usr/*' \ + '*/test/*' \ + '*/conan/*' \ + '*/CMakeFiles/*' \ + '*/build*/*' \ + --output-file coverage_cleaned.info \ + --ignore-errors mismatch,gcov,unused + + # Check final coverage + echo "Final coverage report:" + lcov --list coverage_cleaned.info + mv coverage_cleaned.info coverage.info + else + echo "Coverage file not created, skipping removal step" + fi - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: From 2c6caaf04884707a197e4c0b38fa67ee993fe3f3 Mon Sep 17 00:00:00 2001 From: peterlau123 Date: Wed, 26 Nov 2025 23:20:42 +0800 Subject: [PATCH 04/10] fix: fix lambda capture in windows --- test/source/buffer_hub_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/source/buffer_hub_test.cpp b/test/source/buffer_hub_test.cpp index e5af107..ccb5182 100644 --- a/test/source/buffer_hub_test.cpp +++ b/test/source/buffer_hub_test.cpp @@ -89,7 +89,7 @@ TEST_F(CPUBufferHubTest, ConcurrentAddSizeLevel) { // Each thread adds multiple size levels for (int t = 0; t < num_threads; ++t) { - threads.emplace_back([this, t, &success_count]() { + threads.emplace_back([this, t, &success_count, num_levels_per_thread]() { for (int i = 0; i < num_levels_per_thread; ++i) { // Create unique sizes for each thread to avoid conflicts uint64_t size_bytes = (1 << 20) * (t * num_levels_per_thread + i + 100); // 100MB+ @@ -153,7 +153,7 @@ TEST_F(CPUBufferHubTest, ConcurrentGetBlock) { // Multiple threads requesting blocks of the same size concurrently for (int t = 0; t < num_threads; ++t) { - threads.emplace_back([this, t, &thread_blocks, &successful_gets]() { + threads.emplace_back([this, t, &thread_blocks, &successful_gets, blocks_per_thread]() { for (int i = 0; i < blocks_per_thread; ++i) { auto* block = getBufferHub()->getBlock(Size(4096)); // 4KB blocks if (block != nullptr && block->data != nullptr) { From 539723b4c93cf832d7476be67163106f536550bc Mon Sep 17 00:00:00 2001 From: peterlau123 Date: Wed, 26 Nov 2025 23:44:29 +0800 Subject: [PATCH 05/10] fix: fix the symbol export in windows --- include/NovaLLM/common/device.h | 6 +++--- test/CMakeLists.txt | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/NovaLLM/common/device.h b/include/NovaLLM/common/device.h index eee659a..39cb16c 100644 --- a/include/NovaLLM/common/device.h +++ b/include/NovaLLM/common/device.h @@ -10,9 +10,9 @@ struct DeviceTypeFlags { public: [[nodiscard]] bool has(DeviceType type) const; - void set(DeviceType type); + NOVA_LLM_API void set(DeviceType type); - void clear(DeviceType type); + NOVA_LLM_API void clear(DeviceType type); [[nodiscard]] constexpr DeviceType get() const; @@ -20,4 +20,4 @@ struct DeviceTypeFlags { uint32_t flags_ = 0; }; -} // namespace nova_llm \ No newline at end of file +} // namespace nova_llm diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b1472ec..394c538 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -33,8 +33,8 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/conan/include ) -target_link_libraries(${PROJECT_NAME} - PRIVATE +target_link_libraries(${PROJECT_NAME} + PRIVATE NovaLLM::NovaLLM GTest::gtest GTest::gtest_main @@ -46,6 +46,11 @@ target_link_libraries(${PROJECT_NAME} set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17) +# Define import macro for Windows (tests consume the DLL, library exports) +if(WIN32) + target_compile_definitions(${PROJECT_NAME} PRIVATE NOVA_LLM_IMPORTS) +endif() + # enable compiler warnings if(NOT TEST_INSTALLED_VERSION) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") From afd3b9b7f679438005f9b529c8b3d79dad242051 Mon Sep 17 00:00:00 2001 From: peterlau123 Date: Thu, 27 Nov 2025 00:11:11 +0800 Subject: [PATCH 06/10] fix: fix symbol export of API in windows --- source/memory/buffer_hub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/memory/buffer_hub.cpp b/source/memory/buffer_hub.cpp index a412052..9672d24 100644 --- a/source/memory/buffer_hub.cpp +++ b/source/memory/buffer_hub.cpp @@ -65,7 +65,7 @@ std::vector DefaultSizeLevelStrategy::gigaByteSizes() { } } // namespace -std::vector LevelAssignStrategy::assignLevels() { +NOVA_LLM_API std::vector LevelAssignStrategy::assignLevels() { std::vector ret; ret.insert(ret.end(), DefaultSizeLevelStrategy::byteSizes().begin(), DefaultSizeLevelStrategy::byteSizes().end()); ret.insert(ret.end(), DefaultSizeLevelStrategy::kiloByteSizes().begin(), DefaultSizeLevelStrategy::kiloByteSizes().end()); From 0c23533343a0b91e03c73fcef5a6fcd68a9cac13 Mon Sep 17 00:00:00 2001 From: peterlau123 Date: Thu, 27 Nov 2025 00:33:32 +0800 Subject: [PATCH 07/10] feat: add API export in windows --- include/NovaLLM/common/device.h | 2 +- include/NovaLLM/memory/buffer_hub.h | 6 +++--- source/memory/buffer_hub.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/NovaLLM/common/device.h b/include/NovaLLM/common/device.h index 39cb16c..619ca9f 100644 --- a/include/NovaLLM/common/device.h +++ b/include/NovaLLM/common/device.h @@ -8,7 +8,7 @@ enum class DeviceType : uint32_t { UNKNOWN = 0, CPU = 0x01, CUDA = 0x02, METAL = struct DeviceTypeFlags { public: - [[nodiscard]] bool has(DeviceType type) const; + NOVA_LLM_API [[nodiscard]] bool has(DeviceType type) const; NOVA_LLM_API void set(DeviceType type); diff --git a/include/NovaLLM/memory/buffer_hub.h b/include/NovaLLM/memory/buffer_hub.h index 2d0a113..d96124e 100644 --- a/include/NovaLLM/memory/buffer_hub.h +++ b/include/NovaLLM/memory/buffer_hub.h @@ -24,7 +24,7 @@ namespace nova_llm { // Forward declaration class BufferHub; -struct Size { +struct NOVA_LLM_API Size { private: uint64_t bytes_ = 0; @@ -71,7 +71,7 @@ class LevelAssignStrategy { virtual std::vector assignLevels(); }; -class BufferHubConfig { +class NOVA_LLM_API BufferHubConfig { public: BufferHubConfig(DeviceType device_type, IAllocatorSharedPtr allocator, Size size_limit=Size(4UL*1024*1024*1024), LevelAssignStrategy strategy = LevelAssignStrategy(), float warning_level = 0.95f) : device_type_(device_type), @@ -110,7 +110,7 @@ class BufferHub; * @brief Buffers at the specified size level * */ -class BufferHubLevel { +class NOVA_LLM_API BufferHubLevel { public: // Default constructor required for unordered_map BufferHubLevel() = default; diff --git a/source/memory/buffer_hub.cpp b/source/memory/buffer_hub.cpp index 9672d24..a412052 100644 --- a/source/memory/buffer_hub.cpp +++ b/source/memory/buffer_hub.cpp @@ -65,7 +65,7 @@ std::vector DefaultSizeLevelStrategy::gigaByteSizes() { } } // namespace -NOVA_LLM_API std::vector LevelAssignStrategy::assignLevels() { +std::vector LevelAssignStrategy::assignLevels() { std::vector ret; ret.insert(ret.end(), DefaultSizeLevelStrategy::byteSizes().begin(), DefaultSizeLevelStrategy::byteSizes().end()); ret.insert(ret.end(), DefaultSizeLevelStrategy::kiloByteSizes().begin(), DefaultSizeLevelStrategy::kiloByteSizes().end()); From 53a80464b0d7272e4380414cb74f836528f962be Mon Sep 17 00:00:00 2001 From: peterlau123 Date: Thu, 27 Nov 2025 00:41:48 +0800 Subject: [PATCH 08/10] fix: fix deleted function error --- include/NovaLLM/memory/buffer_hub.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/NovaLLM/memory/buffer_hub.h b/include/NovaLLM/memory/buffer_hub.h index d96124e..8731680 100644 --- a/include/NovaLLM/memory/buffer_hub.h +++ b/include/NovaLLM/memory/buffer_hub.h @@ -114,7 +114,15 @@ class NOVA_LLM_API BufferHubLevel { public: // Default constructor required for unordered_map BufferHubLevel() = default; - + + // Move constructor and assignment for unique_ptr compatibility + BufferHubLevel(BufferHubLevel&&) = default; + BufferHubLevel& operator=(BufferHubLevel&&) = default; + + // Copy operations deleted to prevent unique_ptr copying + BufferHubLevel(const BufferHubLevel&) = delete; + BufferHubLevel& operator=(const BufferHubLevel&) = delete; + void initialize(uint32_t index, const Size& block_size, BufferHub* hub); // Returns non-owning pointer since pool retains ownership @@ -208,7 +216,7 @@ class NOVA_LLM_API BufferHub { // Thread safety: protects all mutable state mutable std::mutex mutex_; - std::unordered_map buffers_; + std::unordered_map, SizeHash, SizeEqual> buffers_; DeviceType device_type_; @@ -227,3 +235,4 @@ class NOVA_LLM_API BufferHub { #ifdef _MSC_VER #pragma warning(pop) #endif +#endif From d4bbf4505a2c93460508f60a1609626e9160c7ac Mon Sep 17 00:00:00 2001 From: peterlau123 Date: Thu, 27 Nov 2025 00:47:33 +0800 Subject: [PATCH 09/10] fix: fix error of compiling --- include/NovaLLM/common/device.h | 4 ++-- include/NovaLLM/memory/buffer_hub.h | 3 +-- source/memory/buffer_hub.cpp | 14 +++++++------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/NovaLLM/common/device.h b/include/NovaLLM/common/device.h index 619ca9f..bb248eb 100644 --- a/include/NovaLLM/common/device.h +++ b/include/NovaLLM/common/device.h @@ -8,13 +8,13 @@ enum class DeviceType : uint32_t { UNKNOWN = 0, CPU = 0x01, CUDA = 0x02, METAL = struct DeviceTypeFlags { public: - NOVA_LLM_API [[nodiscard]] bool has(DeviceType type) const; + [[nodiscard]] NOVA_LLM_API bool has(DeviceType type) const; NOVA_LLM_API void set(DeviceType type); NOVA_LLM_API void clear(DeviceType type); - [[nodiscard]] constexpr DeviceType get() const; + [[nodiscard]] NOVA_LLM_API constexpr DeviceType get() const; private: uint32_t flags_ = 0; diff --git a/include/NovaLLM/memory/buffer_hub.h b/include/NovaLLM/memory/buffer_hub.h index 8731680..bbb2512 100644 --- a/include/NovaLLM/memory/buffer_hub.h +++ b/include/NovaLLM/memory/buffer_hub.h @@ -66,7 +66,7 @@ using BlockPtr = std::unique_ptr; // Raw non-owning pointer for temporary access using BlockRawPtr = Block*; -class LevelAssignStrategy { +class NOVA_LLM_API LevelAssignStrategy { public: virtual std::vector assignLevels(); }; @@ -235,4 +235,3 @@ class NOVA_LLM_API BufferHub { #ifdef _MSC_VER #pragma warning(pop) #endif -#endif diff --git a/source/memory/buffer_hub.cpp b/source/memory/buffer_hub.cpp index a412052..8836e4a 100644 --- a/source/memory/buffer_hub.cpp +++ b/source/memory/buffer_hub.cpp @@ -266,7 +266,7 @@ void BufferHub::addSizeLevel(uint32_t index, const Size& level_block_sz) { std::lock_guard lock(mutex_); auto& level = buffers_[level_block_sz]; - level.initialize(index, level_block_sz, this); + level->initialize(index, level_block_sz, this); } void BufferHub::eraseSizeLevel(const Size& level_sz) { @@ -279,16 +279,16 @@ void BufferHub::eraseSizeLevel(const Size& level_sz) { } auto& level = it->second; - if (level.busyBlockCount() > 0) { + if (level->busyBlockCount() > 0) { LOG_ERROR("Level with size %llu has %zu busy blocks, cannot erase now", - level_sz.totalBytes(), level.busyBlockCount()); + level_sz.totalBytes(), level->busyBlockCount()); return; } // Free all blocks in the block_list before erasing // The destructor will be called, but let's be explicit about cleanup LOG_INFO("Erasing level with size %llu, freeing %zu blocks", - level_sz.totalBytes(), level.totalBlocks()); + level_sz.totalBytes(), level->totalBlocks()); // Erasing from the map will call BufferHubLevel destructor, // which properly frees all blocks via tearDownBlock @@ -307,7 +307,7 @@ BlockRawPtr BufferHub::getBlock(const Size& sz) { BlockRawPtr ret_block {nullptr}; if (buffers_.count(level_sz)) { auto& level = buffers_[level_sz]; - auto block = level.fetchOneFreeBlock(); + auto block = level->fetchOneFreeBlock(); if (block && block->isValid()) { ret_block = block; } @@ -329,7 +329,7 @@ void BufferHub::putBlock(BlockRawPtr block_ptr) { Size level_size(size); if (buffers_.count(level_size)) { auto& level = buffers_[level_size]; - level.putOneBlock(block_ptr); + level->putOneBlock(block_ptr); } else { LOG_ERROR("Level size %d is not found in buffers!", level_size.totalBytes()); } @@ -346,7 +346,7 @@ void BufferHub::putBlockFromBuffer(Buffer& buffer) { auto& level = buffers_[level_sz]; auto* data = static_cast(buffer.data); - if (!level.tryPutBlock(data)) { + if (!level->tryPutBlock(data)) { // Maybe log warning if data was expected to be there? // But original code just did nothing if not found in busy_map. // Actually original code: if (level.busy_map.count(data)) { ... } From a2a1e1fb09d6b9089aec205f064d447d33d7b96d Mon Sep 17 00:00:00 2001 From: peterlau123 Date: Thu, 27 Nov 2025 00:55:54 +0800 Subject: [PATCH 10/10] fix: fix capture error on macos --- test/source/buffer_hub_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/source/buffer_hub_test.cpp b/test/source/buffer_hub_test.cpp index ccb5182..3356a57 100644 --- a/test/source/buffer_hub_test.cpp +++ b/test/source/buffer_hub_test.cpp @@ -89,7 +89,7 @@ TEST_F(CPUBufferHubTest, ConcurrentAddSizeLevel) { // Each thread adds multiple size levels for (int t = 0; t < num_threads; ++t) { - threads.emplace_back([this, t, &success_count, num_levels_per_thread]() { + threads.emplace_back([this, t, &success_count, num_levels_per_thread=num_levels_per_thread]() { for (int i = 0; i < num_levels_per_thread; ++i) { // Create unique sizes for each thread to avoid conflicts uint64_t size_bytes = (1 << 20) * (t * num_levels_per_thread + i + 100); // 100MB+ @@ -153,7 +153,7 @@ TEST_F(CPUBufferHubTest, ConcurrentGetBlock) { // Multiple threads requesting blocks of the same size concurrently for (int t = 0; t < num_threads; ++t) { - threads.emplace_back([this, t, &thread_blocks, &successful_gets, blocks_per_thread]() { + threads.emplace_back([this, t, &thread_blocks, &successful_gets, blocks_per_thread=blocks_per_thread]() { for (int i = 0; i < blocks_per_thread; ++i) { auto* block = getBufferHub()->getBlock(Size(4096)); // 4KB blocks if (block != nullptr && block->data != nullptr) {