simplewallet: warn when mining thread count exceeds CPU cores
What changed, and why it matters
This change adds a friendly yellow warning in Monero's command-line wallet when a user tries to mine with more threads than their CPU actually has. It does not change any security behavior, permissions, or network logic; it only gives performance advice to the user.
No security action needed. This is a usability/performance improvement. Reviewers can treat it as a normal feature commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds a runtime check in simple_wallet::start_mining() that compares the requested mining thread count against boost::thread::hardware_concurrency(). If the requested count exceeds available hardware threads, it prints a non-blocking warning message. No input validation, RPC parameters, or daemon behavior is altered.
Changed components
src/simplewallet/simplewallet.cppsimple_wallet::start_miningInspect captured patch +6 / −0
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 4904059..6c0c6a5 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -5383,6 +5383,12 @@ bool simple_wallet::start_mining(const std::vector<std::string>& args)
return true;
}
+ const unsigned int hw_concurrency = boost::thread::hardware_concurrency();
+ if (hw_concurrency && req.threads_count > hw_concurrency)
+ {
+ message_writer(console_color_yellow, false) << boost::format(tr("Warning: %u mining threads requested exceeds the %u hardware threads available on this CPU. Consider using %u for best performance.")) % req.threads_count % hw_concurrency % hw_concurrency;
+ }
+
COMMAND_RPC_START_MINING::response res;
bool r = m_wallet->invoke_http_json("/start_mining", req, res);
std::string err = interpret_rpc_response(r, res.status);
Why this scored 16/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.