perf(runtime): reduce worker I/O overhead in multiprocess mode

This commit is contained in:
2026-03-30 01:20:52 +02:00
parent 8c124a4a85
commit 940d291b09

View File

@@ -123,7 +123,9 @@ int run_mining_loop(const MinerConfig *cfg, int worker_idx, const char *extranon
return 1;
}
fprintf(stdout, "[main] chain=%s worker=%d extranonce2=%s\n", chain, worker_idx, extranonce2);
if (event_fd < 0) {
fprintf(stdout, "[main] chain=%s worker=%d extranonce2=%s\n", chain, worker_idx, extranonce2);
}
status_ctx.event_fd = event_fd;
status_ctx.worker_idx = worker_idx;
@@ -164,7 +166,9 @@ int run_mining_loop(const MinerConfig *cfg, int worker_idx, const char *extranon
}
}
fprintf(stdout, "[main] template height=%d tx=%zu segwit=%d\n", tpl.height, tpl.tx_count, witness_count);
if (event_fd < 0) {
fprintf(stdout, "[main] template height=%d tx=%zu segwit=%d\n", tpl.height, tpl.tx_count, witness_count);
}
if (build_coinbase_transaction(
&tpl,
@@ -243,7 +247,7 @@ int run_mining_loop(const MinerConfig *cfg, int worker_idx, const char *extranon
putchar('\n');
}
if (atomic_load(&new_block_flag) != 0) {
if (event_fd < 0 && atomic_load(&new_block_flag) != 0) {
fprintf(stdout, "[main] nuovo best block: riavvio ciclo\n");
}
@@ -283,7 +287,9 @@ int run_mining_loop(const MinerConfig *cfg, int worker_idx, const char *extranon
}
if (block_hash != NULL) {
fprintf(stdout, "[main] block trovato: %s\n", block_hash);
if (event_fd < 0) {
fprintf(stdout, "[main] block trovato: %s\n", block_hash);
}
emit_eventf(event_fd, "found %d %.6f\n", worker_idx, result.hashrate_hz / 1000.0);
emit_eventf(event_fd, "hash %d %s\n", worker_idx, block_hash);
}