Merge pull request #5959 from str4d/improve-thread-names
Improve thread names
This commit is contained in:
commit
202203a3fa
|
@ -982,6 +982,7 @@ dependencies = [
|
||||||
"orchard",
|
"orchard",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"rand_core 0.6.3",
|
"rand_core 0.6.3",
|
||||||
|
"rayon",
|
||||||
"secp256k1",
|
"secp256k1",
|
||||||
"secrecy",
|
"secrecy",
|
||||||
"subtle",
|
"subtle",
|
||||||
|
|
|
@ -57,6 +57,9 @@ zcash_proofs = "0.6"
|
||||||
ed25519-zebra = "3"
|
ed25519-zebra = "3"
|
||||||
zeroize = "1.4.2"
|
zeroize = "1.4.2"
|
||||||
|
|
||||||
|
# Rust threading
|
||||||
|
rayon = "1.5"
|
||||||
|
|
||||||
# Metrics
|
# Metrics
|
||||||
ipnet = "2"
|
ipnet = "2"
|
||||||
metrics = "0.17"
|
metrics = "0.17"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||||
|
|
||||||
#include "asyncrpcqueue.h"
|
#include "asyncrpcqueue.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
static std::atomic<size_t> workerCounter(0);
|
static std::atomic<size_t> workerCounter(0);
|
||||||
|
|
||||||
|
@ -26,6 +27,8 @@ AsyncRPCQueue::~AsyncRPCQueue() {
|
||||||
* A worker will execute this method on a new thread
|
* A worker will execute this method on a new thread
|
||||||
*/
|
*/
|
||||||
void AsyncRPCQueue::run(size_t workerId) {
|
void AsyncRPCQueue::run(size_t workerId) {
|
||||||
|
std::string s = strprintf("zc-asyncrpc-%s", workerId);
|
||||||
|
RenameThread(s.c_str());
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
AsyncRPCOperationId key;
|
AsyncRPCOperationId key;
|
||||||
|
|
|
@ -43,6 +43,10 @@ static bool fDaemon;
|
||||||
|
|
||||||
void WaitForShutdown(boost::thread_group* threadGroup)
|
void WaitForShutdown(boost::thread_group* threadGroup)
|
||||||
{
|
{
|
||||||
|
// This is the main process thread, but after this point, all we do here is wait for
|
||||||
|
// shutdown, and then shut down the node.
|
||||||
|
RenameThread("zc-wait-to-stop");
|
||||||
|
|
||||||
bool fShutdown = ShutdownRequested();
|
bool fShutdown = ShutdownRequested();
|
||||||
// Tell the main threads to shutdown.
|
// Tell the main threads to shutdown.
|
||||||
while (!fShutdown)
|
while (!fShutdown)
|
||||||
|
|
|
@ -289,7 +289,7 @@ static void http_reject_request_cb(struct evhttp_request* req, void*)
|
||||||
/** Event dispatcher thread */
|
/** Event dispatcher thread */
|
||||||
static bool ThreadHTTP(struct event_base* base, struct evhttp* http)
|
static bool ThreadHTTP(struct event_base* base, struct evhttp* http)
|
||||||
{
|
{
|
||||||
RenameThread("zcash-http");
|
RenameThread("zc-http-server");
|
||||||
LogPrint("http", "Entering http event loop\n");
|
LogPrint("http", "Entering http event loop\n");
|
||||||
event_base_dispatch(base);
|
event_base_dispatch(base);
|
||||||
// Event loop will be interrupted by InterruptHTTPServer()
|
// Event loop will be interrupted by InterruptHTTPServer()
|
||||||
|
@ -339,7 +339,7 @@ static bool HTTPBindAddresses(struct evhttp* http)
|
||||||
/** Simple wrapper to set thread name and run work queue */
|
/** Simple wrapper to set thread name and run work queue */
|
||||||
static void HTTPWorkQueueRun(WorkQueue<HTTPClosure>* queue)
|
static void HTTPWorkQueueRun(WorkQueue<HTTPClosure>* queue)
|
||||||
{
|
{
|
||||||
RenameThread("zcash-httpworker");
|
RenameThread("zc-http-worker");
|
||||||
queue->Run();
|
queue->Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
#include "zmq/zmqnotificationinterface.h"
|
#include "zmq/zmqnotificationinterface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <rust/init.h>
|
||||||
#include <rust/metrics.h>
|
#include <rust/metrics.h>
|
||||||
|
|
||||||
#include "librustzcash.h"
|
#include "librustzcash.h"
|
||||||
|
@ -1071,6 +1072,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
|
|
||||||
std::set_new_handler(new_handler_terminate);
|
std::set_new_handler(new_handler_terminate);
|
||||||
|
|
||||||
|
// Set up global Rayon threadpool.
|
||||||
|
zcashd_init_rayon_threadpool();
|
||||||
|
|
||||||
// ********************************************************* Step 2: parameter interactions
|
// ********************************************************* Step 2: parameter interactions
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
|
|
||||||
|
@ -1438,7 +1442,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
!fPrintToConsole && !GetBoolArg("-daemon", false)) {
|
!fPrintToConsole && !GetBoolArg("-daemon", false)) {
|
||||||
// Start the persistent metrics interface
|
// Start the persistent metrics interface
|
||||||
ConnectMetricsScreen();
|
ConnectMetricsScreen();
|
||||||
threadGroup.create_thread(&ThreadShowMetricsScreen);
|
threadGroup.create_thread(
|
||||||
|
boost::bind(&TraceThread<void (*)()>, "metrics-ui", &ThreadShowMetricsScreen)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize Zcash circuit parameters
|
// Initialize Zcash circuit parameters
|
||||||
|
|
|
@ -3029,7 +3029,7 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
|
||||||
static CCheckQueue<CScriptCheck> scriptcheckqueue(128);
|
static CCheckQueue<CScriptCheck> scriptcheckqueue(128);
|
||||||
|
|
||||||
void ThreadScriptCheck() {
|
void ThreadScriptCheck() {
|
||||||
RenameThread("zcash-scriptch");
|
RenameThread("zc-scriptcheck");
|
||||||
scriptcheckqueue.Thread();
|
scriptcheckqueue.Thread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -601,9 +601,6 @@ bool enableVTMode()
|
||||||
|
|
||||||
void ThreadShowMetricsScreen()
|
void ThreadShowMetricsScreen()
|
||||||
{
|
{
|
||||||
// Make this thread recognisable as the metrics screen thread
|
|
||||||
RenameThread("zcash-metrics-screen");
|
|
||||||
|
|
||||||
// Determine whether we should render a persistent UI or rolling metrics
|
// Determine whether we should render a persistent UI or rolling metrics
|
||||||
bool isTTY = isatty(STDOUT_FILENO);
|
bool isTTY = isatty(STDOUT_FILENO);
|
||||||
bool isScreen = GetBoolArg("-metricsui", isTTY);
|
bool isScreen = GetBoolArg("-metricsui", isTTY);
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright (c) 2022 The Zcash developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||||
|
|
||||||
|
#ifndef ZCASH_RUST_INCLUDE_RUST_INIT_H
|
||||||
|
#define ZCASH_RUST_INCLUDE_RUST_INIT_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Initializes the global Rayon threadpool.
|
||||||
|
void zcashd_init_rayon_threadpool();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // ZCASH_RUST_INCLUDE_RUST_INIT_H
|
|
@ -0,0 +1,7 @@
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn zcashd_init_rayon_threadpool() {
|
||||||
|
rayon::ThreadPoolBuilder::new()
|
||||||
|
.thread_name(|i| format!("zc-rayon-{}", i))
|
||||||
|
.build_global()
|
||||||
|
.expect("Only initialized once");
|
||||||
|
}
|
|
@ -77,6 +77,7 @@ mod builder_ffi;
|
||||||
mod history_ffi;
|
mod history_ffi;
|
||||||
mod incremental_merkle_tree;
|
mod incremental_merkle_tree;
|
||||||
mod incremental_merkle_tree_ffi;
|
mod incremental_merkle_tree_ffi;
|
||||||
|
mod init_ffi;
|
||||||
mod orchard_ffi;
|
mod orchard_ffi;
|
||||||
mod orchard_keys_ffi;
|
mod orchard_keys_ffi;
|
||||||
mod transaction_ffi;
|
mod transaction_ffi;
|
||||||
|
|
|
@ -192,7 +192,7 @@ void RenameThread(const char* name);
|
||||||
*/
|
*/
|
||||||
template <typename Callable> void TraceThread(const char* name, Callable func)
|
template <typename Callable> void TraceThread(const char* name, Callable func)
|
||||||
{
|
{
|
||||||
std::string s = strprintf("zcash-%s", name);
|
std::string s = strprintf("zc-%s", name);
|
||||||
RenameThread(s.c_str());
|
RenameThread(s.c_str());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -1134,7 +1134,7 @@ DBErrors CWalletDB::ZapWalletTx(CWallet* pwallet, vector<CWalletTx>& vWtx)
|
||||||
void ThreadFlushWalletDB(const string& strFile)
|
void ThreadFlushWalletDB(const string& strFile)
|
||||||
{
|
{
|
||||||
// Make this thread recognisable as the wallet flushing thread
|
// Make this thread recognisable as the wallet flushing thread
|
||||||
RenameThread("zcash-wallet");
|
RenameThread("zc-wallet-flush");
|
||||||
|
|
||||||
static bool fOneThread;
|
static bool fOneThread;
|
||||||
if (fOneThread)
|
if (fOneThread)
|
||||||
|
|
Loading…
Reference in New Issue