sgminer-dev / sgminer

Scrypt GPU miner
GNU General Public License v3.0
629 stars 825 forks source link

quits at 60 sec if not on default-profile #286

Closed badman74 closed 10 years ago

badman74 commented 10 years ago

i am running windows 7 if i have profiles configured and it is not on the default-profile or it isnt specified then the miner quits after 60 sec

ystarnaud commented 10 years ago

Can you link your config?

troky commented 10 years ago

I have the same problem. Bug is introduced in #282

ystarnaud commented 10 years ago

I tracked down the issue to the algorithm switcher and this seems to be a problem with the windows implementation of pthread. I managed to fix this problem in a test build but it's a dirty hack in my view.

if (unlikely(pthread_create(&restart_thr, NULL, restart_mining_threads_thread, (void *) (intptr_t) n_threads)))
        quit(1, "restart_mining_threads create thread failed");
sleep(60);
quit(1, "thread was not cancelled in 60 seconds after restart_mining_threads");

At the end of the algo switcher, a thread (restart_thr) is launched to restart all mining threads/gpus and returns NULL when done. The parent thread meanwhile sleeps 60 seconds and if the timeout is reached, sgminer assumes that something went wrong and quits.

I'm not overly knowledgeable with pthread but under linux, when the restart thread returns NULL, somehow the parent thread returns also, cancelling the 60 seconds timeout. No issues there.

Under windows, however, the restart thread returns NULL and nothing happens. The parent thread still waits for the timeout and eventually reaches it even tho everything is ok. This causes sgminer to quit.

Does anyone have an idea why this is happening? I can release my fix but it's not a long term solution in my opinion...

ystarnaud commented 10 years ago

I'm guessing this has been a problem in the algo switcher for a while now. See #269

troky commented 10 years ago

Here are my config and log: Log: http://pastebin.com/QSWvq1TF Config: http://pastebin.com/B9xjRKLB Profiles: http://pastebin.com/fB9apbNg

I tried config with default-profile but problem remains.

@ystarnaud I am not sure this is (only) algo switcher problem because before #282 everything worked fine with the same config.

Dirty hack is to comment line (for win32): quit(1, "thread was not cancelled in 60 seconds after restart_mining_threads"); I've been running sgminer without above line for 12h. No problems nor (visible) memory leaks.

ystarnaud commented 10 years ago

@troky Ok, your config doesn't have an algorithm set at the global level (outside of pools or profiles) and you don't have a default-profile set to load an algorithm from. This makes sgminer load ckolivas at startup.

Now this is what happens: sgminer starts with an initial algo, In your case ckolivas. Sgminer looks for the first alive pool to hash on. It finds pool 0, tmb x11. Pool 0 wants darkcoin-mod, but ckolivas is loaded. Algo switcher comes into play, darkcoin-mod is loaded, pool 0 starts hashing. The thread issue I mentioned above happens, sgminer exits.

If you set a default-profile, this can happen also. Say your default profile was x13, marucoin-mod would be loaded at sgminer startup. Pool 0 is alive, wants darkcoin-mod. Algo switcher happens, sgminer exits after 60 seconds.

This only happens on windows. My solution was to set a boolean variable globally. Once the restart thread was done, it would set it to true. When the timeout happened, and the variable was true, it would cancel the thread and avoid quitting sgminer.

troky commented 10 years ago

There is some logic questions here we need to solve:

  1. Why is default profile initialized on startup even if it is not used in any of pools? There is no need to build unused kernel.
  2. Is default-profile setting mandatory? Why not fall back to first profile defined in profiles?
  3. Why do we need global algorithm? Every profile should have algorithm set and if it isn't set throw config error.
ystarnaud commented 10 years ago

@troky Granted, my implementation has had a few flaws and I address them as people bring them to my attention. I do plenty of testing of my own but I can't account for everyone's particular configs or system builds. That being said here are answers to your questions:

  1. I've been looking into this one. My work was on the config parser at first and not how the core of sgminer runs. Default profile as the name implies are just system defaults. It replaces the old global variables like opt_algoritm, opt_gpu_engine, etc... it's basically what everything falls back on when you don't specify it in your profile or pool config. Global level options populate it or you can load it from one of your existing profiles. The thing is that sgminer initializes GPUs before an alive pool is even found and with it the kernel module selected at startup. This process needs to be switched around but I haven't gotten to that yet. Anyone is welcome to fix this.
  2. default-profile IS NOT mandatory. If you don't specify anything there, global level settings populate it like in old style configs. If you don't have global level settings then sgminer core defaults come into play. I can set it to fall back to profile 0 but again, it won't solve problems with the core of sgminer.
  3. You don't need an algorithm set at the global level but If you don't set one and don't have one in your default-profile, ckolivas is loaded. That has been in sgminer before I even started contributing.
troky commented 10 years ago

@ystarnaud

  1. I know this is core issue not config. Just wanted to say it should be soved :) 2&3. Now when I specify both default-profile and algorithm in global config sgminer doesn't quit after 60s. Strange... I've been trying to find out what went south after #282 for hours but without success so far.

Waiting for @mrbrdo for pthrads sleep/quit fix or workaround on windows.

ystarnaud commented 10 years ago

Give the latest commits a shot. I believe I solved a few things and hopefully didn't create new issues...

troky commented 10 years ago

It works for me. With or without default-profile setting.

platinum4 commented 10 years ago

I'd say we can close this as of build 4.2.1-178-g7801