From d3af0b04b263e179fda8284c594bf3e6adb1462d Mon Sep 17 00:00:00 2001 From: Julian Waller Date: Fri, 24 May 2024 14:37:15 +0100 Subject: [PATCH] Revert "fix: replace tbbmalloc with os native implementations" tbbmalloc is necessary on windows to get satisfactory performance in many cases #1537 This reverts commit 3816e08f5b89cd1139a4c46a47bb1aef2b6b15f4. --- src/CMakeModules/Bootstrap_Windows.cmake | 4 ++++ src/common/memshfl.h | 3 ++- src/shell/CMakeLists.txt | 2 ++ src/shell/main.cpp | 7 +++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/CMakeModules/Bootstrap_Windows.cmake b/src/CMakeModules/Bootstrap_Windows.cmake index a7d22f0d8c..e47d0d5a3f 100644 --- a/src/CMakeModules/Bootstrap_Windows.cmake +++ b/src/CMakeModules/Bootstrap_Windows.cmake @@ -109,6 +109,10 @@ set(TBB_BIN_PATH "${SOURCE_DIR}/redist/intel64/vc14") link_directories("${SOURCE_DIR}/lib/intel64/vc14") casparcg_add_runtime_dependency("${TBB_BIN_PATH}/tbb12.dll" "Release") casparcg_add_runtime_dependency("${TBB_BIN_PATH}/tbb12_debug.dll" "Debug") +casparcg_add_runtime_dependency("${TBB_BIN_PATH}/tbbmalloc.dll" "Release") +casparcg_add_runtime_dependency("${TBB_BIN_PATH}/tbbmalloc_debug.dll" "Debug") +casparcg_add_runtime_dependency("${TBB_BIN_PATH}/tbbmalloc_proxy.dll" "Release") +casparcg_add_runtime_dependency("${TBB_BIN_PATH}/tbbmalloc_proxy_debug.dll" "Debug") # GLEW casparcg_add_external_project(glew) diff --git a/src/common/memshfl.h b/src/common/memshfl.h index 3947e9867f..8c69e23302 100644 --- a/src/common/memshfl.h +++ b/src/common/memshfl.h @@ -26,6 +26,7 @@ #include #else #ifdef _MSC_VER +#include #include #else #include @@ -37,7 +38,7 @@ namespace caspar { #ifdef _MSC_VER static std::shared_ptr create_aligned_buffer(size_t size) { - return std::shared_ptr(_aligned_malloc(size, 64), _aligned_free); + return std::shared_ptr(scalable_aligned_malloc(size, 64), scalable_aligned_free); } #else static std::shared_ptr create_aligned_buffer(size_t size) diff --git a/src/shell/CMakeLists.txt b/src/shell/CMakeLists.txt index a7c4857536..f35aa25dab 100644 --- a/src/shell/CMakeLists.txt +++ b/src/shell/CMakeLists.txt @@ -55,7 +55,9 @@ if (MSVC) Winmm.lib Ws2_32.lib optimized tbb.lib + optimized tbbmalloc.lib debug tbb_debug.lib + debug tbbmalloc_debug.lib OpenGL32.lib glew32.lib openal32.lib diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 8c9ebe679f..eea4404c81 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -19,10 +19,17 @@ * Author: Robert Nagy, ronag89@gmail.com */ +// tbbmalloc_proxy: +// Replace the standard memory allocation routines in Microsoft* C/C++ RTL +// (malloc/free, global new/delete, etc.) with the TBB memory allocator +// as the default allocator suffers from low performance. + #if defined _DEBUG && defined _MSC_VER #define _CRTDBG_MAP_ALLOC #include #include +#elif defined _MSC_VER +#include #endif #include "included_modules.h"