git: kernel - Refactor scheduler weightings part 2/2.

Matthew Dillon dillon at
Mon May 27 21:48:48 PDT 2019

commit 4871f0f439ab7e3daa36852ff48cb9f488734716
Author: Matthew Dillon <dillon at>
Date:   Sun May 26 17:20:48 2019 -0700

    kernel - Refactor scheduler weightings part 2/2.
    * Change the default fork()ing mechanic from 0x80 (random cpu) to
      0x20 (best cpu).  We no longer need to mix it up on fork because
      weight4 now works.
    * The best cpu algorithm has a number of desirable characteristics
      for fork() and fork()/exec().
      - Will generally start the child topologically 'close' to the parent,
        reducing fork/exec/exit/wait overheads, but still spread the children
        out while machine load is light.  If the child sticks around for
        long enough, it will get spread out even more optimally.  If not,
        closer is better.
      - Will not stack children up on the same cpu unnecessarily (e.g. parent
        fork()s a bunch of times at once).
      - Will optimize heavy and very-heavy load situations.  If the child
        have nowhere else reasonable to go, this will schedule it on a
        hyper-thread sibling or even on the same cpu as the parent.  Depending
        on the load.
    * Gives us around a 15% improvement in fork/exec/exit/wait performance.
    * Once a second we clear the td_wakefromcpu hint on the currently
      running thread.  This allows a thread which has become cpu-bound
      to start to 'wander' afield (though the scheduler will still try to
      avoid moving it too far away, topologically).

Summary of changes:
 sys/kern/kern_clock.c  | 10 +++++++++-
 sys/kern/kern_fork.c   |  1 +
 sys/kern/usched_dfly.c | 14 +++++++++++---
 3 files changed, 21 insertions(+), 4 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list