From 70e84b8e2ca9aa59dd9a5ebabe039f5d778ab7db Mon Sep 17 00:00:00 2001 From: techy2 Date: Wed, 28 Feb 2024 19:53:33 -0800 Subject: [PATCH] improve TIP following cpu usage, upgrade to boost.1.84 problem: qt daemon uses significant cpu resources while following the tip. solution: update /depends/ boost library to 1.84 change main.h typedef BlockMap ... mapBlockIndex from std::unordered_map to boost::unordered_map to take advantage of reduced cpu usage during "tip" following. see benchmark info: https://www.boost.org/doc/libs/develop/libs/unordered/doc/html/unordered.html#buckets_benchmarks https://medium.com/@pavel.odintsov/boost-unordered-map-is-a-new-king-of-data-structures-292124d3ee2 --- depends/packages/boost.mk | 11 +++++------ src/httpserver.cpp | 1 + src/qt/clientmodel.cpp | 3 +++ src/qt/pivx/pivxgui.cpp | 1 + src/qt/pivx/splash.cpp | 2 ++ src/qt/transactiontablemodel.cpp | 2 ++ src/qt/walletmodel.cpp | 1 + src/validationinterface.cpp | 2 ++ src/wallet/walletdb.cpp | 5 +++-- 9 files changed, 20 insertions(+), 8 deletions(-) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 7425963dd..a4d0298cf 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,9 +1,9 @@ package=boost -$(package)_version=1_71_0 -# $(package)_download_path=https://boostorg.jfrog.io/artifactory/main/release/$(subst _,.,$($(package)_version))/source/ -$(package)_download_path=https://github.com/decenomy/depends/raw/main/ +$(package)_version=1_84_0 +$(package)_download_path=https://boostorg.jfrog.io/artifactory/main/release/$(subst _,.,$($(package)_version))/source/ +# $(package)_download_path=https://github.com/decenomy/depends/raw/main/ $(package)_file_name=boost_$($(package)_version).tar.bz2 -$(package)_sha256_hash=d73a8da01e8bf8c7eda40b4c84915071a8c8a0df4a6734537ddde4a8580524ee +$(package)_sha256_hash=cc4b893acf645c9d4b698e9a0f08ca8846aa5d6c68275c14c3e7949c24109454 $(package)_patches=fix_gcc_11_3_compile.patch define $(package)_set_vars @@ -31,8 +31,7 @@ $(package)_cxxflags_linux=-fPIC endef define $(package)_preprocess_cmds - echo "using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : \"$($(package)_cxxflags) $($(package)_cppflags)\" \"$($(package)_ldflags)\" \"$(boost_archiver_$(host_os))\" \"$(host_STRIP)\" \"$(host_RANLIB)\" \"$(host_WINDRES)\" : ;" > user-config.jam && \ - patch -p1 -i $($(package)_patch_dir)/fix_gcc_11_3_compile.patch + echo "using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : \"$($(package)_cxxflags) $($(package)_cppflags)\" \"$($(package)_ldflags)\" \"$(boost_archiver_$(host_os))\" \"$(host_STRIP)\" \"$(host_RANLIB)\" \"$(host_WINDRES)\" : ;" > user-config.jam endef define $(package)_config_cmds diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 83a7049fb..1eb7d18d1 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 1278952c4..4f1fb1b85 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -5,6 +5,7 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include "clientmodel.h" #include "bantablemodel.h" @@ -29,6 +30,8 @@ #include #include +using namespace boost::placeholders; + static const int64_t nClientStartupTime = GetTime(); // Last tip update notification static int64_t nLastBlockTipUpdateNotification = 0; diff --git a/src/qt/pivx/pivxgui.cpp b/src/qt/pivx/pivxgui.cpp index 881bbd953..40f83edd7 100644 --- a/src/qt/pivx/pivxgui.cpp +++ b/src/qt/pivx/pivxgui.cpp @@ -36,6 +36,7 @@ #define BASE_WINDOW_MIN_HEIGHT 620 #define BASE_WINDOW_MIN_WIDTH 1100 +using namespace boost::placeholders; const QString PIVXGUI::DEFAULT_WALLET = "~Default"; diff --git a/src/qt/pivx/splash.cpp b/src/qt/pivx/splash.cpp index c49a35fbf..a4793da68 100644 --- a/src/qt/pivx/splash.cpp +++ b/src/qt/pivx/splash.cpp @@ -24,6 +24,8 @@ #include +using namespace boost::placeholders; + Splash::Splash(Qt::WindowFlags f, const NetworkStyle* networkStyle) : QWidget(0, f | Qt::SplashScreen), ui(new Ui::Splash) { diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 96c1a27c3..b3a491755 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -30,6 +30,8 @@ #include #include +using namespace boost::placeholders; + // Amount column is right-aligned it contains numbers static int column_alignments[] = { Qt::AlignLeft | Qt::AlignVCenter, /* status */ diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index f4c8e4f66..864336389 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -29,6 +29,7 @@ #include #include +using namespace boost::placeholders; WalletModel::WalletModel(CWallet* wallet, OptionsModel* optionsModel, QObject* parent) : QObject(parent), wallet(wallet), walletWrapper(*wallet), optionsModel(optionsModel), diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp index 2733f56d2..ca586d564 100644 --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -7,6 +7,8 @@ #include "validationinterface.h" +using namespace boost::placeholders; + static CMainSignals g_signals; CMainSignals& GetMainSignals() diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 2f0f393f0..166ff66bc 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -24,7 +24,6 @@ #include #include - static uint64_t nAccountingEntryNumber = 0; static std::atomic nWalletDBUpdateCounter; @@ -1069,7 +1068,9 @@ bool AttemptBackupWallet(const CWallet& wallet, const fs::path& pathSrc, const f LogPrintf("cannot backup to wallet source file %s\n", pathDest.string()); return false; } -#if BOOST_VERSION >= 105800 /* BOOST_LIB_VERSION 1_58 */ +#if BOOST_VERSION >= 107400 /* BOOST_LIB_VERSION 1_74 */ + fs::copy_file(pathSrc.c_str(), pathDest, fs::copy_options::overwrite_existing); +#elif BOOST_VERSION >= 105800 /* BOOST_LIB_VERSION 1_58 */ fs::copy_file(pathSrc.c_str(), pathDest, fs::copy_option::overwrite_if_exists); #else std::ifstream src(pathSrc.c_str(), std::ios::binary | std::ios::in);