Skip to content
This repository has been archived by the owner on Apr 24, 2022. It is now read-only.

Reconnect #1135

Merged
merged 13 commits into from
May 25, 2018
Merged

Reconnect #1135

merged 13 commits into from
May 25, 2018

Conversation

AndreaLanfranchi
Copy link
Collaborator

  • Made boost's io_service global
  • No stops of io_service which prevent restart of resolver or sockets
  • On disconnects this behavior is implemented : mining is stopped only
    if switching pools (failovers) otherwise it keeps mining trying a fast
    reconnect on same pool
  • SSL and plain TCP reconnect properly on Linux

Feed back needed on Windows.

AndreaLanfranchi and others added 5 commits May 22, 2018 14:15
Attempt to solve problems related to disconnect/reconnect for timeouts
on responses or no-work.
On PoolManager the IO_SERVICE is now persistent and never exits

On Linux
* Disconnect/Reconnect without issues for plain TCP connections
* SSL Connections get shut down properly but at first reconnect attempt
it goes timeout. After that reconnection is immediate.

On Windows
* Feedback needed.
Reconnects ok.
* Made boost's io_service global
* No stops of io_service which prevent restart of resolver or sockets
* On disconnects this behavior is implemented : mining is stopped only
if switching pools (failovers) otherwise it keeps mining trying a fast
reconnect on same pool
* SSL and plain TCP reconnect properly on Linux

Feed back needed on Windows.
@smurfy
Copy link
Collaborator

smurfy commented May 22, 2018

Does not work on windows :(

 m  18:59:03|main    |  ethminer 0.15.0.dev10-31+commit.a713f035
  m  18:59:03|main    |  Build: windows / release
 cu  18:59:03|main    |  Using grid size 8192 , block size 128
  m  18:59:04|main    |  not-connected
  i  18:59:04|<unknown>|  Selected pool eu2.ethermine.org:4444
  i  18:59:04|stratum |  Trying 91.121.222.33:4444 ...
  i  18:59:04|stratum |  Connected to eu2.ethermine.org  [91.121.222.33:4444]
  i  18:59:04|stratum |  Spinning up miners...
  i  18:59:04|cuda-0  |  No work. Pause for 3 s.
  i  18:59:04|stratum |  Subscribed to stratum server
  i  18:59:04|stratum |  Authorized worker xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  i  18:59:04|stratum |  New job #ba78aacf...   eu2.ethermine.org [91.121.222.33:4444]
  i  18:59:04|stratum |  New pool difficulty:  4.00 gigahashes
  i  18:59:07|cuda-0  |  Initialising miner 0
 cu  18:59:07|cuda-0  |  Using device: GeForce GTX 1080  (Compute 6.1)
  i  18:59:08|stratum |  New job #6e6d01bd...   eu2.ethermine.org [91.121.222.33:4444]
 cu  18:59:08|cuda-0  |  Set Device to current
 cu  18:59:08|cuda-0  |  Resetting device
 cu  18:59:08|cuda-0  |  Allocating light with size: 41418304
 cu  18:59:08|cuda-0  |  Generating mining buffers
 cu  18:59:08|cuda-0  |  Generating DAG for GPU # 0  with dagSize: 2650796416  gridSize: 8192
  m  18:59:09|main    |  Speed   0.00 Mh/s    gpu/0  0.00 43C 0%   [A0+0:R0+0:F0] Time: 00:00
  i  18:59:11|stratum |  New job #1b8b7a5e...   eu2.ethermine.org [91.121.222.33:4444]
  m  18:59:14|main    |  Speed   0.00 Mh/s    gpu/0  0.00 47C 0%   [A0+0:R0+0:F0] Time: 00:00
  m  18:59:19|main    |  Speed   0.00 Mh/s    gpu/0  0.00 48C 0%   [A0+0:R0+0:F0] Time: 00:00
  m  18:59:24|main    |  Speed  17.99 Mh/s    gpu/0 17.99 49C 0%   [A0+0:R0+0:F0] Time: 00:00
  m  18:59:29|main    |  Speed  20.92 Mh/s    gpu/0 20.92 51C 0%   [A0+0:R0+0:F0] Time: 00:00
  i  18:59:30|stratum |  New job #0967348d...   eu2.ethermine.org [91.121.222.33:4444]
  i  18:59:31|stratum |  New job #fdb95779...   eu2.ethermine.org [91.121.222.33:4444]
  i  18:59:33|stratum |  New job #b9ba2339...   eu2.ethermine.org [91.121.222.33:4444]
  m  18:59:34|main    |  Speed  21.18 Mh/s    gpu/0 21.18 52C 0%   [A0+0:R0+0:F0] Time: 00:00
  m  18:59:39|main    |  Speed  20.80 Mh/s    gpu/0 20.80 53C 2%   [A0+0:R0+0:F0] Time: 00:00
  m  18:59:44|main    |  Speed  20.92 Mh/s    gpu/0 20.92 54C 6%   [A0+0:R0+0:F0] Time: 00:00
  m  18:59:49|main    |  Speed  21.09 Mh/s    gpu/0 21.09 56C 10%   [A0+0:R0+0:F0] Time: 00:00
  m  18:59:54|main    |  Speed  20.92 Mh/s    gpu/0 20.92 56C 13%   [A0+0:R0+0:F0] Time: 00:00
  m  18:59:59|main    |  Speed  20.96 Mh/s    gpu/0 20.96 57C 16%   [A0+0:R0+0:F0] Time: 00:00
  m  19:00:04|main    |  Speed  20.85 Mh/s    gpu/0 20.85 58C 19%   [A0+0:R0+0:F0] Time: 00:01
  m  19:00:09|main    |  Speed  20.83 Mh/s    gpu/0 20.83 59C 21%   [A0+0:R0+0:F0] Time: 00:01
  m  19:00:14|main    |  Speed  20.92 Mh/s    gpu/0 20.92 59C 23%   [A0+0:R0+0:F0] Time: 00:01
  m  19:00:19|main    |  Speed  20.94 Mh/s    gpu/0 20.94 60C 25%   [A0+0:R0+0:F0] Time: 00:01
  X  19:00:24|stratum |  Socket read failed: The semaphore timeout period has expired
  i  19:00:24|stratum |  Disconnected from eu2.ethermine.org  [91.121.222.33:4444]
  m  19:00:24|main    |  not-connected
  i  19:00:24|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:00:24|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:00:24|stratum |  Disconnected from eu2.ethermine.org  [91.121.222.33:4444]
  m  19:00:29|main    |  not-connected
  m  19:00:34|main    |  not-connected
  m  19:00:39|main    |  not-connected
  m  19:00:44|main    |  not-connected
  m  19:00:49|main    |  not-connected
  m  19:00:54|main    |  not-connected
  m  19:00:59|main    |  not-connected
  m  19:01:04|main    |  not-connected
  m  19:01:09|main    |  not-connected
  m  19:01:14|main    |  not-connected
  m  19:01:19|main    |  not-connected
  m  19:01:24|main    |  not-connected
  m  19:01:29|main    |  not-connected
  m  19:01:34|main    |  not-connected
  m  19:01:39|main    |  not-connected
  m  19:01:44|main    |  not-connected
  i  19:01:46|cuda-0  |  Nonce 0x75a85ea55cff11b2 wasted. Waiting for connection ...
  m  19:01:49|main    |  not-connected
  m  19:01:54|main    |  not-connected
  m  19:01:59|main    |  not-connected
  m  19:02:04|main    |  not-connected
  m  19:02:09|main    |  not-connected

@AndreaLanfranchi
Copy link
Collaborator Author

Ok. This log makes sense to me.
Pushing correction.

@smurfy
Copy link
Collaborator

smurfy commented May 22, 2018

Works now, but consider adding some kind of delay for reconnecting:

  m  19:40:10|main    |  Speed  20.88 Mh/s    gpu/0 20.88 60C 23%   [A0+0:R0+0:F0] Time: 00:01
  m  19:40:15|main    |  Speed  20.72 Mh/s    gpu/0 20.72 60C 25%   [A0+0:R0+0:F0] Time: 00:01
  m  19:40:20|main    |  Speed  20.71 Mh/s    gpu/0 20.71 60C 27%   [A0+0:R0+0:F0] Time: 00:01
  X  19:40:24|stratum |  Socket read failed: The semaphore timeout period has expired
  i  19:40:24|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  m  19:40:25|main    |  not-connected
  i  19:40:25|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:25|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:25|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:26|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:26|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:26|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:27|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:27|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:27|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:28|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:28|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:28|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:29|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:29|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:29|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  m  19:40:30|main    |  not-connected
  i  19:40:30|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:30|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:30|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:31|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:31|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:31|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:32|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:32|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:32|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:33|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:33|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:33|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:34|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:34|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:34|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  m  19:40:35|main    |  not-connected
  i  19:40:35|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:35|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:35|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:36|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:36|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:36|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:37|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:37|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:37|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:38|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:38|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:38|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:39|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:39|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:39|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  m  19:40:40|main    |  not-connected
  i  19:40:40|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:40|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:40|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:41|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:41|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:41|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:42|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:42|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:42|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:44|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:44|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:44|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:45|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:45|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:45|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  m  19:40:45|main    |  not-connected
  i  19:40:46|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:46|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:46|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:47|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:47|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:47|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:48|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:48|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:48|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:49|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:49|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:49|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:50|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:50|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:50|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  m  19:40:50|main    |  not-connected
  i  19:40:51|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:51|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:51|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:52|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:52|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:52|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:53|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:53|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:53|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:54|cuda-0  |  Nonce 0x5565a821ee603805 wasted. Waiting for connection ...
  i  19:40:54|<unknown>|  Selected pool eu2.ethermine.org:4444
  X  19:40:54|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  19:40:54|stratum |  Disconnected from eu2.ethermine.org  [46.105.121.53:4444]
  i  19:40:55|<unknown>|  Selected pool eu2.ethermine.org:4444
  i  19:40:55|stratum |  Trying 94.23.36.128:4444 ...
  i  19:40:55|stratum |  Connected to eu2.ethermine.org  [94.23.36.128:4444]
  i  19:40:55|stratum |  Subscribed to stratum server
  i  19:40:55|stratum |  Authorized worker xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  i  19:40:55|stratum |  New job #1e14900f...   eu2.ethermine.org [94.23.36.128:4444]
  m  19:40:55|main    |  Speed  21.04 Mh/s    gpu/0 21.04 62C 33%   [A0+0:R0+0:F0] Time: 00:01
  i  19:40:57|stratum |  New job #759d66e7...   eu2.ethermine.org [94.23.36.128:4444]
  m  19:41:00|main    |  Speed  20.88 Mh/s    gpu/0 20.88 62C 34%   [A0+0:R0+0:F0] Time: 00:01

@AndreaLanfranchi
Copy link
Collaborator Author

Ok ... need some adjustments.
Behavior to be expected is :

  • On disconnection from pool PoolManager tries as many "fast" reconnections to the same pool as are defined in --farm-retries argument. "Fast" reconnection means no stop of mining as we're supposed to reconnect to the same pool.
  • On connection switching mining is stopped and a delay of 3 seconds is addedd.
  • If the next pool in switching process is an "exit" pool then the workloop simply stops and ethminer exits

@smurfy
Copy link
Collaborator

smurfy commented May 22, 2018

TCP and SSL WORK

  m  20:02:17|main    |  Speed  20.55 Mh/s    gpu/0 20.55 62C 33%   [A0+0:R0+0:F0] Time: 00:00
  m  20:02:22|main    |  Speed  20.55 Mh/s    gpu/0 20.55 62C 34%   [A0+0:R0+0:F0] Time: 00:01
  m  20:02:27|main    |  Speed  20.55 Mh/s    gpu/0 20.55 62C 34%   [A0+0:R0+0:F0] Time: 00:01
  m  20:02:32|main    |  Speed  20.55 Mh/s    gpu/0 20.55 63C 35%   [A0+0:R0+0:F0] Time: 00:01
  m  20:02:37|main    |  Speed  20.34 Mh/s    gpu/0 20.34 63C 35%   [A0+0:R0+0:F0] Time: 00:01
  X  20:02:41|stratum |  Socket read failed: The semaphore timeout period has expired
  i  20:02:41|stratum |  Disconnected from eu2.ethermine.org  [91.121.167.111:5555]
  m  20:02:42|main    |  not-connected
  i  20:02:42|<unknown>|  Selected pool eu2.ethermine.org:5555
  X  20:02:42|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  20:02:42|stratum |  Disconnected from eu2.ethermine.org  [91.121.167.111:5555]
  i  20:02:43|<unknown>|  Selected pool eu2.ethermine.org:5555
  X  20:02:43|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  20:02:43|stratum |  Disconnected from eu2.ethermine.org  [91.121.167.111:5555]
  i  20:02:44|<unknown>|  Selected pool eu2.ethermine.org:5555
  X  20:02:44|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  20:02:44|stratum |  Disconnected from eu2.ethermine.org  [91.121.167.111:5555]
  i  20:02:45|<unknown>|  Shutting down miners...
  i  20:02:45|<unknown>|  Retrying in 3 ...
  i  20:02:46|<unknown>|  Retrying in 2 ...
  m  20:02:47|main    |  not-connected
  i  20:02:47|<unknown>|  Retrying in 1 ...
  i  20:02:48|<unknown>|  Selected pool eu2.ethermine.org:5555
  X  20:02:48|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  20:02:48|stratum |  Disconnected from eu2.ethermine.org  [91.121.167.111:5555]
  i  20:02:49|<unknown>|  Selected pool eu2.ethermine.org:5555
  X  20:02:49|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  20:02:49|stratum |  Disconnected from eu2.ethermine.org  [91.121.167.111:5555]
  i  20:02:50|<unknown>|  Selected pool eu2.ethermine.org:5555
  X  20:02:50|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  20:02:50|stratum |  Disconnected from eu2.ethermine.org  [91.121.167.111:5555]
  i  20:02:51|<unknown>|  Selected pool eu2.ethermine.org:5555
  X  20:02:51|stratum |  Could not resolve host eu2.ethermine.org , No such host is known
  i  20:02:51|stratum |  Disconnected from eu2.ethermine.org  [91.121.167.111:5555]
  m  20:02:52|main    |  not-connected
  i  20:02:52|<unknown>|  Selected pool eu2.ethermine.org:5555
  i  20:02:52|stratum |  Trying 91.121.167.111:5555 ...
  i  20:02:52|stratum |  Connected to eu2.ethermine.org  [91.121.167.111:5555]
  i  20:02:52|stratum |  Spinning up miners...
  i  20:02:52|cuda-0  |  No work. Pause for 3 s.
  i  20:02:52|stratum |  Subscribed to stratum server
  i  20:02:52|stratum |  Authorized worker xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  i  20:02:52|stratum |  New job #38e24458...   eu2.ethermine.org [91.121.167.111:5555]
  i  20:02:55|cuda-0  |  Initialising miner 0
 cu  20:02:55|cuda-0  |  Using device: GeForce GTX 1080  (Compute 6.1)
 cu  20:02:55|cuda-0  |  Set Device to current
 cu  20:02:55|cuda-0  |  Resetting device
 cu  20:02:55|cuda-0  |  Allocating light with size: 41418304
 cu  20:02:55|cuda-0  |  Generating mining buffers
 cu  20:02:55|cuda-0  |  Generating DAG for GPU # 0  with dagSize: 2650796416  gridSize: 8192
  m  20:02:57|main    |  Speed   0.00 Mh/s    gpu/0  0.00 61C 36%   [A0+0:R0+0:F0] Time: 00:01
  m  20:03:02|main    |  Speed   0.00 Mh/s    gpu/0  0.00 62C 36%   [A0+0:R0+0:F0] Time: 00:01

@AndreaLanfranchi
Copy link
Collaborator Author

Finally !!!

I think this solves a good bunch of problems.

@paddymahoney
Copy link

Seems to improve resiliency for me across a modem reboot. +1

@paddymahoney
Copy link

Tested on linux and windows, resiliency of process plain better, reiterate +1

{
// Post first deadline timer to give io_service
// initial work
m_io_work_timer.expires_from_now(boost::posix_time::seconds(60));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this fake job is needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every time io_service starts allocates it's own thread_pool.
When there are no more jobs in the poll queue it destroys all it's threads and recreation is very long time consuming. Also on Windows apparently it does not restart properly.
This fake job gives the poll queue always something to do so it never stops.

@@ -542,6 +584,7 @@ class MinerCLI
if (m_minerType == MinerType::CUDA || m_minerType == MinerType::Mixed)
CUDAMiner::listDevices();
#endif
stop_io_service();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try return from function instead of exit().

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not change the logic of functions not related to the scope of this pr.
Exit was there before: I only addedd the stop_io_service before exiting.

m_noEval,
m_exit
)) {
stop_io_service();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stop_io_service() seems to be a bad pattern. Is there a way to start the service only when needed?

Long term, I have better way of handling list of devices.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I start the io_service at MinerCLI constructor thus I need to stop it whenever MinerCLI exits

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also ... aside from list-devices asio_service is always needed.

@@ -783,10 +833,12 @@ class MinerCLI
sealers["cuda"] = Farm::SealerDescriptor{&CUDAMiner::instances, [](FarmFace& _farm, unsigned _index){ return new CUDAMiner(_farm, _index); }};
#endif

//EthStratumClient::pointer client = EthStratumClient::create(m_worktimeout, m_responsetimeout, m_email, m_report_stratum_hashrate);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete old code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wilco

m_io_service.reset();
m_serviceThread.join();
}
//if (m_serviceThread.joinable()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete old code

std::thread m_serviceThread; ///< The IO service thread.
boost::asio::io_service m_io_service;

// std::thread m_serviceThread; ///< The IO service thread.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete old code.

// Workloop will determine if we're trying a fast reconnect to same pool
// or if we're switching to failover(s)

//if (m_farm.isMining()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete old code.

unsigned m_reconnectTries = 3;
unsigned m_reconnectTry = 0;
std::vector <URI> m_connections;
std::atomic<bool> m_running = { false };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also g_running flag. Can this be combined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combining global running semaphore (which is only affected by signal capturing) with m_running on PoolManager requires a sensible redesign of running pattern and, at least, remove (on PoolManager) the start and stop methods as they would make no sense.
Nevertheless actual separation of running ethminer process from PoolManager service may (or may not) be helpful to implement further features like, say for example, bind to recent added feature --tstart/--tstop where poolconnection might be suspended in case all gpu exceed temperature threshold.

Anyway I would leave this task outside the scope of this specific PR.

// Otherwise do nothing and wait until connection state is NOT pending
if (!p_client->isPendingState()) {

dev::setThreadName("main");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want to do this in a loop.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not ?
It's conditional and happens quite unfrequently.
Anyway I can't see clearly any other place where to place it to have the thread properly labelled in output logs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just do it once in the beginning of the function?

@AndreaLanfranchi
Copy link
Collaborator Author

The whole point of this PR is to have a io_service globally and persistently running. Otherwise reconnect would not happen.

@chfast
Copy link
Contributor

chfast commented May 24, 2018

Please also add an entry to CHANGELOG.md.

@chfast
Copy link
Contributor

chfast commented May 24, 2018

Hey @AndreaLanfranchi, two question have not been addressed here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants