mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
kernel: Remove batchpriority from kernel library
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 choose their own scheduling policy.
This commit is contained in:
parent
6f1d906438
commit
d4b17c7d46
3 changed files with 56 additions and 58 deletions
|
@ -975,7 +975,6 @@ libbitcoinkernel_la_SOURCES = \
|
|||
txdb.cpp \
|
||||
txmempool.cpp \
|
||||
uint256.cpp \
|
||||
util/batchpriority.cpp \
|
||||
util/chaintype.cpp \
|
||||
util/check.cpp \
|
||||
util/feefrac.cpp \
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
#include <txdb.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/asmap.h>
|
||||
#include <util/batchpriority.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/check.h>
|
||||
#include <util/fs.h>
|
||||
|
@ -1735,6 +1736,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
}
|
||||
|
||||
chainman.m_thread_load = std::thread(&util::TraceThread, "initload", [=, &chainman, &args, &node] {
|
||||
ScheduleBatchPriority();
|
||||
// Import blocks
|
||||
ImportBlocks(chainman, vImportFiles);
|
||||
if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
|
||||
|
|
|
@ -1175,9 +1175,6 @@ public:
|
|||
|
||||
void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFiles)
|
||||
{
|
||||
ScheduleBatchPriority();
|
||||
|
||||
{
|
||||
ImportingNow imp{chainman.m_blockman.m_importing};
|
||||
|
||||
// -reindex
|
||||
|
@ -1237,7 +1234,7 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
|
|||
return;
|
||||
}
|
||||
}
|
||||
} // End scope of ImportingNow
|
||||
// End scope of ImportingNow
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const BlockfileType& type) {
|
||||
|
|
Loading…
Add table
Reference in a new issue