bitcoin-pow / BitcoinPoW

BitcoinPoW
https://bitcoin-pow.org
MIT License
16 stars 6 forks source link

miningthreads option not working for stage 2 #54

Closed rtmooney closed 2 months ago

rtmooney commented 3 months ago

CPU jumps to 100%. This occurs after finding a kernel, as seen in the debug logs. I assume it has to do with the 2nd part of mining. I've had it happen multiple times on both Windows 11 and Ubuntu Noble. This also happens on both of my computers (AMD 12 core, AMD 6 core). I have let it sit for hours with no let up. Both wallets were downloaded, not compiled from the source code. Multiple sized wallets (20k and up) were used and multiple cpu loading/threads, as well. Is the 2nd part of mining not controlled with the -cpuloading option?

Relevant log output

2024-07-28T10:29:35Z [mining] CreateCoinStake : kernel found 2024-07-28T10:29:35Z [mining] CreateCoinStake : parsed kernel type=pubkeyhash 2024-07-28T10:29:35Z [mining] CreateCoinStake : added kernel type=pubkeyhash 2024-07-28T10:29:35Z [bench] CreateNewBlock() packages: 0.02ms (1 packages, 0 updated descendants), validity: 0.21ms (total 0.22ms) 2024-07-28T10:29:36Z [mining] CreateCoinStake : kernel found 2024-07-28T10:29:36Z [mining] CreateCoinStake : parsed kernel type=pubkeyhash 2024-07-28T10:29:36Z [mining] CreateCoinStake : added kernel type=pubkeyhash

How did you obtain Bitcoin Core

Pre-built binaries

What version of Bitcoin Core are you using?

26.4.1

Operating system and version

Windows 11 and Ubuntu Noble

Machine specifications

7900x 12 core, 3600xt 6 core.

bitcoin-pow commented 3 months ago

Thanks for your bug find.

The cpuloading and miningthreads options were originally created for controlling the original mining. These parameters still control the stage one mining, but have no effect on the stage 2 mining. We could carry these parameters over to cover both stage 1 and stage 2 mining.

This is a low priority bug as most miners want their CPU near 100% to maximize their chance of mining a block. This would be a good first issue for a new developer to contribute.

wajtecek commented 2 months ago

Hej,

In change log you rote:; "This will fail because the amount of work to do (1) is about 1% of the total work and the remaining 99% of the work is in (2)"

Is that mean that whole of computer power with using all threads etc will be consumed only for 1% of whole work? Rest 99% will use... I don't know - one thread?

If so I think this is pretty high priority bug.

bitcoin-pow commented 2 months ago

Stage 2 will use all computer threads at 100% loading which should load all CPU cores near 100%. Stage 1 is the same as before, it is controlled by cpuloading and mining threads options. This means that the user can have all CPU cores loaded 100% for the entire block with the current code; this is why it is a very low priority bug.

wajtecek commented 2 months ago

Thank you for explanation.

wajtecek commented 2 months ago

Could you additionally in wallet.cpp remove/change part which is responsible for: // Target 95.0% cpu loading - Each mining round is a one second interval, it we get too close to 100% loading we will start // missing our 1 second bucket which results in a loss of hashpower. This isn't traditional PoW, we only get unique // calculations on 1 second boundaries. This is similar to digital communications where we try to align to 1PPS.

As I understand correctly if I put -cpuloading option bigger than 95 (%), this part of code will try to drop some... power to reach 95%.

Is that correct? Or am I misleading again? :P

bitcoin-pow commented 2 months ago

You are confusing comments for code. The interval will run for your given value of cpuloading, however the comment is just informing that there is overhead code and running just under 100% per 1 second bucket will result in a more optimal mining.

bitcoin-pow commented 2 months ago

cpuloading and miningthreads options are not needed as a pair. There is no reason to have cpu loading, when we can control overall loading by increasing/decreasing the number of mining threads anyway. If a mining thread is enabled, it will always be set to 100% loading.