0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

Merge bitcoin/bitcoin#30083: kernel: Remove batchpriority from kernel library

d4b17c7d46 kernel: Remove batchpriority from kernel library (TheCharlatan)

Pull request description:

  The current usage of ScheduleBatchPriority is not transparent. Once the thread scheduling is changed, it remains unchanged for the remainder of the thread's lifetime. So move the call from `ImportBlocks` to the init code where it is clearer that its effect lasts for the entire lifetime of the thread.

  Users of the kernel library might not expect `ImportBlocks` to have an influence on the thread it is called in. Particularly since it is only a compile time option and cannot be controlled at runtime. With this patch users of the kernel library can now freely choose their own scheduling policy.

  This PR is easier reviewed with `git diff --color-moved-ws=ignore-all-space --color-moved=dimmed-zebra`

  ---
  This PR is part of the [libbitcoinkernel project](https://github.com/bitcoin/bitcoin/issues/27587).

ACKs for top commit:
  maflcko:
    ACK d4b17c7d46 📭
  ryanofsky:
    Code review ACK d4b17c7d46, just added suggested comment since last review
  hebasto:
    ACK d4b17c7d46, I have reviewed the code and it looks OK.

Tree-SHA512: cafedecd9affad58ddd7f30f68bba71291ca951bb186ff4b2da04b7f21f0b26e5e3143846d032b9e391bd5ce6c7466b97aa3758d2a85ebd7353eb8b69139641a
This commit is contained in:
Ryan Ofsky 2024-05-14 11:17:42 -04:00
commit dbb3113082
No known key found for this signature in database
GPG key ID: 46800E30FC748A66
3 changed files with 56 additions and 58 deletions

View file

@ -974,7 +974,6 @@ libbitcoinkernel_la_SOURCES = \
txdb.cpp \ txdb.cpp \
txmempool.cpp \ txmempool.cpp \
uint256.cpp \ uint256.cpp \
util/batchpriority.cpp \
util/chaintype.cpp \ util/chaintype.cpp \
util/check.cpp \ util/check.cpp \
util/feefrac.cpp \ util/feefrac.cpp \

View file

@ -71,6 +71,7 @@
#include <txdb.h> #include <txdb.h>
#include <txmempool.h> #include <txmempool.h>
#include <util/asmap.h> #include <util/asmap.h>
#include <util/batchpriority.h>
#include <util/chaintype.h> #include <util/chaintype.h>
#include <util/check.h> #include <util/check.h>
#include <util/fs.h> #include <util/fs.h>
@ -1741,6 +1742,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
} }
chainman.m_thread_load = std::thread(&util::TraceThread, "initload", [=, &chainman, &args, &node] { chainman.m_thread_load = std::thread(&util::TraceThread, "initload", [=, &chainman, &args, &node] {
ScheduleBatchPriority();
// Import blocks // Import blocks
ImportBlocks(chainman, vImportFiles); ImportBlocks(chainman, vImportFiles);
if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) { if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {

View file

@ -1174,9 +1174,6 @@ public:
}; };
void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFiles) void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFiles)
{
ScheduleBatchPriority();
{ {
ImportingNow imp{chainman.m_blockman.m_importing}; ImportingNow imp{chainman.m_blockman.m_importing};
@ -1237,7 +1234,7 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
return; return;
} }
} }
} // End scope of ImportingNow // End scope of ImportingNow
} }
std::ostream& operator<<(std::ostream& os, const BlockfileType& type) { std::ostream& operator<<(std::ostream& os, const BlockfileType& type) {