cpuminer: Improve speed stat tracking. #1921
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, in order to allow both the normal continuous and discrete CPU mining modes, a non-blocking channel send is used to update the number of hashes per second since the speed monitor is not running or required in discrete mode.
As a result, in the case the total hashes are already being updated by another goroutine, the update will be ignored which can lead to reporting a lower hash rate than is accurate.
In order to better handle the aforementioned case, this modifies the code to introduce a separate struct with its own mutex to be used for tracking the speed stats and uses a unique instance for the continuous and discrete mining modes. A separate instance is used to ensure the discrete mining mode is unable to interfere with the continuous mode stats.