Author

Topic: bitcoin auto-renice-ing (Read 50910 times)

founder
Activity: 364
Merit: 7423
July 14, 2010, 12:38:31 PM
#7
Laszlo corrected this, but unfortunately it was too late to make it into 0.3.0.  There will probably be a 0.3.1 soon though.

The problem is I used PRIO_MIN, I should have used PRIO_MAX for the lowest priority.  The OS isn't supposed to let you increase priority, so the PRIO_MIN ought to leave it at priority 0.
newbie
Activity: 38
Merit: 0
July 12, 2010, 06:11:24 PM
#6
lachesis - htop
its awesome.. has ANSI colors, you can fully configure it to display all threads, tree view, etc ,etc
full member
Activity: 210
Merit: 105
July 12, 2010, 06:02:48 PM
#5
Asdfman, what program is generating that output? I like it Cheesy
newbie
Activity: 38
Merit: 0
newbie
Activity: 38
Merit: 0
July 12, 2010, 03:05:57 AM
#3
Hello,

This same behavior was bugging me too.. I would renice all the threads to 19, as it was interrupting system responsiveness since bitcoind was taking priority, but every so often the program would automatically reset the priority to something that would disrupt system responsiveness ..
so what I did was just edit util.h
and change the function that manipulates the priority:

inline void SetThreadPriority(int nPriority)
{
    printf("No, were not changing any damn priority\n");
}

and then recompiled bitcoind

now I just renice all the threads once, and they are stuck at what I set them to until program exit (NI column staying at 19):

Code:
   1  [||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%]     Time: 03:59:40
  2  [||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%]     Uptime: 253 days(!), 01:12:27
  Mem[||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||501/1255MB]     Load: 4.01
  Swp[||||||||||||||||||||||||||||||||||||||||||||||||||||||                                            501/1004MB]     Load average: 4.01 4.15 3.49
         __   __         __   __        __  __   __         __   __         __   __         __   __                             __  __              __
        |  | |__         __| |__       |__||__  |__|       |  | |  |       |  | |  |       |  | |  |                            __| __|   |           |
  Avg:  |__|.|__|% sy:  |__ . __|% ni:  __||__|.|__|% hi:  |__|.|__|% si:  |__|.|__|% wa:  |__|.|__|%                   Tasks:  __| __|   | total,    | running

  PID USER     PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command

 4523 root      39  19  126M 46280  3424 S  0.0  3.6  0:00.66  `- bitcoind -gen -daemon
 4534 root      39  19  126M 46280  3424 R 90.0  3.6 12:43.73  |   `- bitcoind -gen -daemon
 4533 root      39  19  126M 46280  3424 R 45.0  3.6 10:49.02  |   `- bitcoind -gen -daemon
 4532 root      39  19  126M 46280  3424 R 46.0  3.6 10:05.83  |   `- bitcoind -gen -daemon
 4531 root      39  19  126M 46280  3424 S  0.0  3.6  0:00.03  |   `- bitcoind -gen -daemon
 4530 root      39  19  126M 46280  3424 S  1.0  3.6  0:15.53  |   `- bitcoind -gen -daemon
 4529 root      39  19  126M 46280  3424 S  0.0  3.6  0:00.72  |   `- bitcoind -gen -daemon
 4527 root      39  19  126M 46280  3424 S  0.0  3.6  0:00.02  |   `- bitcoind -gen -daemon
 4526 root      39  19  126M 46280  3424 S  0.0  3.6  0:00.03  |   `- bitcoind -gen -daemon
 4525 root      39  19  126M 46280  3424 S  0.0  3.6  0:00.06  |   `- bitcoind -gen -daemon
in my debug.log:

[root@raidserv] (~/.bitcoin)# grep "No," debug.log
No, were not changing any damn priority
No, were not changing any damn priority
No, were not changing any damn priority
No, were not changing any damn priority
...

So now I can leave bitcoind running all day long without me noticing much...


founder
Activity: 364
Merit: 7423
March 15, 2010, 01:44:12 PM
#2
It sets different priorities for each thread.  The generate threads run at PRIO_MIN.  The other threads rarely take any CPU and run at normal.

#define THREAD_PRIORITY_LOWEST          PRIO_MIN
#define THREAD_PRIORITY_BELOW_NORMAL    2
#define THREAD_PRIORITY_NORMAL          0

The priorities converted from Windows priorities were probably from a table like this:

   "The following table shows the mapping between nice values and Win32 priorities. Refer to the Win32 documentation for SetThreadPriority() for more information on Win32 priority issues.

nice value    Win32 Priority
-20 to -16    THREAD_PRIORITY_HIGHEST
-15 to -6    THREAD_PRIORITY_ABOVE_NORMAL
-5 to +4    THREAD_PRIORITY_NORMAL
+5 to +14    THREAD_PRIORITY_BELOW_NORMAL
+15 to +19    THREAD_PRIORITY_LOWEST"

If you have better values, suggestions welcome.

Also, there was some advice on the web that PRIO_PROCESS is used on Linux because threads are processes.  If that's not true, maybe it accounts for unexpectedly setting the priority of the whole app.

    // threads are processes on linux, so PRIO_PROCESS affects just the one thread
    setpriority(PRIO_PROCESS, getpid(), nPriority);
sr. member
Activity: 440
Merit: 250
March 08, 2010, 04:29:56 AM
#1
Hi, I run bitcoin at a nice level of 20 so as not to interfere with other tasks.  Every now and then, however, it seems to auto-adjust itself to nice level 2, or even 0.  It this by design?  Frankly, such a thing should be illegal for a linux application... it's a bit odd to say the least.
Jump to: