diff options
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp index efff96c..77aba89 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
| @@ -170,6 +170,26 @@ int MinerThreadCount() | |||
| 170 | return (int)(nCores - 1); | 170 | return (int)(nCores - 1); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | // Hash threads one participant session runs. | ||
| 174 | // | ||
| 175 | // Explicit /hashthreads=N is honored exactly, including 1 -- a miner who says | ||
| 176 | // one means one. Automatic leaves a core to the node, the Stratum I/O loop and | ||
| 177 | // everything else the process still has to do, for the same reason | ||
| 178 | // MinerThreadCount() does. | ||
| 179 | // | ||
| 180 | // Lives here, next to that function, because the two are easy to confuse and | ||
| 181 | // StartMinerThreads() needs to be able to tell them apart: only ONE session | ||
| 182 | // runs in participant mode, and this is what sizes it. | ||
| 183 | int ParticipantHashThreadCount() | ||
| 184 | { | ||
| 185 | if (nHashThreads > 0) | ||
| 186 | return nHashThreads; | ||
| 187 | int nWorkers = (int)AvailableCoreCount(); | ||
| 188 | if (nWorkers < 2) | ||
| 189 | nWorkers = 2; | ||
| 190 | return nWorkers - 1; | ||
| 191 | } | ||
| 192 | |||
| 173 | bool AddKey(const CKey& key) | 193 | bool AddKey(const CKey& key) |
| 174 | { | 194 | { |
| 175 | if (IsWalletEncrypted()) | 195 | if (IsWalletEncrypted()) |
| @@ -3828,13 +3848,11 @@ connected: | |||
| 3828 | // shared dataset), then run the I/O loop below: receive pool messages, | 3848 | // shared dataset), then run the I/O loop below: receive pool messages, |
| 3829 | // publish jobs to the threads, submit the shares they find. | 3849 | // publish jobs to the threads, submit the shares they find. |
| 3830 | // ------------------------------------------------------------------ | 3850 | // ------------------------------------------------------------------ |
| 3831 | int nWorkers = nHashThreads > 0 ? nHashThreads | 3851 | // One count, decided in one place (main.cpp:MinerThreadCount's neighbour), |
| 3832 | : (int)AvailableCoreCount(); | 3852 | // so that what StartMinerThreads() reports at startup and what actually |
| 3833 | if (nHashThreads <= 0) { | 3853 | // hashes here can never drift apart. Explicit /hashthreads=N is honored |
| 3834 | if (nWorkers < 2) nWorkers = 2; | 3854 | // exactly, including 1; automatic leaves one core for node + I/O threads. |
| 3835 | nWorkers -= 1; // leave one core for node + I/O threads | 3855 | int nWorkers = ParticipantHashThreadCount(); |
| 3836 | } | ||
| 3837 | // explicit /hashthreads=N is honored exactly (including 1) | ||
| 3838 | ParticipantJobShared jobShared; | 3856 | ParticipantJobShared jobShared; |
| 3839 | std::vector<ParticipantShareHit> shareHits; | 3857 | std::vector<ParticipantShareHit> shareHits; |
| 3840 | std::mutex shareHitsMtx; | 3858 | std::mutex shareHitsMtx; |