chapel-lang/chapel — pull request #159 by ronawho (2014-08-15 05:05:10+00:00)
Title: Do a qthread_yield() after X number of unlocks on a sync variable

Note: This idea was ok'd and comes from greg and sung. This exact patch hasn't
been reviewed, but it passed full testing and I want to see the performance
results so that we can setup something for good testing over the weekend and
hopefully switch to qthreads as default after the weekend. After seeing the
performance and correctness results I'll update the patch and have it formally
reviewed.

After switching to the nemesis scheduler as the default scheduler for qthreads
we had 5 deadlocks essentially coming from 2 tests:
test/domains/sungeun/assoc/stress.chpl and test/users/shetag/fock/fock-1.chpl.

In these tests the main task is waiting for a sync var to have a certain value
while other tasks are incrementing that sync var. In this case some tasks that
are adding to the sync var are put on to run on the same worker as the main
task. The main task is never yielding and thus it keeps waiting for a sync var
to have a value that it is preventing from getting updated.

To remedy this, we now yield after 256 unlocks of any given sync var. The
specific number has come from some trial and error with the previous tests and
will probably change after some more trial and error and looking through
performance results.

This also lowers the stack size for a test that creates an enormous amount of
threads and turns off guard pages to avoid running out of memory.