Re: Massive performance loss from OS::sleep hack



Daniel Eischen wrote:

When I removed this hack (i.e. revert to pthread_yield()) I got an immediate 7-fold performance increase, which brings FreeBSD performance on par with Solaris.

What is the reason why this code is necessary? Does FreeBSD's sched_yield() really have different semantics to the other operating systems, or was this a libkse bug that was being worked around?

It's certainly not a libkse bug, at least with scope process threads libkse does the right thinng. For scope system threads and all libthr
threads, it probably depends on what scheduler you are using since
it's essentially a __sys_sched_yield().

On a side note, I think pthread_yield() is deprecated and not in the
latest POSIX spec. sched_yield() is in the spec and is specified
to account for behavior in a threaded environment.

Yeah, libthr's pthread_yield just calls sched_yield. Anyway, it seems to me that the decision of what thread to run next is a scheduler decision, and if it is inappropriate for some reason for a scheduler to possibly choose to reschedule the same thread that just yielded, this is something that should be addressed in the scheduler rather than by adding hacks to the application.

Kris

_______________________________________________
freebsd-performance@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-performance
To unsubscribe, send any mail to "freebsd-performance-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Scheduler activations (IIRC) question
    ... a new type of futex with a hook into the scheduler looks ... the kernel is blocking me? ... This is the main fundamental reason for not just running lots of ... Even this "fast path" is two extra syscalls per original syscall. ...
    (Linux-Kernel)
  • Re: cvs commit: src/sys/kern sched_ule.c
    ... I see no reason to do anything other than a count of the number of threads ... > What if a scheduler wants to keep a thread on TWO lists.. ... > thread on BOTH teh percpu queue and an independent queue. ... why don't we simply move the slot code into the generic struct ...
    (freebsd-current)
  • Re: Multi-threaded Performance Pitfalls presentation
    ... need to avoid pitfalls like this: ... one thread to fire timers is a good reason. ... One thread to dispatch requests to a library that does not handle ... Don't rely on the scheduler to tell you what work to do. ...
    (comp.programming.threads)
  • Re: 2.6.4-mm1
    ... >> to set up the SMT scheduler. ... > Am I correct in thinking that this patch provides the necessary hooks to ... I think the reason is that it doesn't do balance on clone/fork. ...
    (Linux-Kernel)
  • Rebooting W2K3 TS Server
    ... No title for this reason could be found ... Shutdown Type: restart ... Any idea why the Scheduler is failing to run the batch file through? ...
    (microsoft.public.windows.terminal_services)

Quantcast