Skip to content

Use a condition variable to control busy threads in dispatch_apply test #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2016

Conversation

chunchenhsu
Copy link

The dispatch_apply test sometimes fails in multicore machines. The
failed function is test_apply_contended which tests if dispatch_apply
can make progress and finish with N concurrent busy threads running,
where N is the number of CPUs. According to the testing log, it fails
because some busy threads already finish before dispatch_apply() is
invoked.

This happens because the test uses the ITERS_PER_SECOND variable to
control the number of iteration of the loop in the busy thread and
optimistically hope the execution time is long enough to complete
the test. But sometimes this hope fails when the testing machine has
greater computing power and more CPU cores.

Instead of using ITERS_PER_SECOND, which makes an assumption about the
computing power of the test machine, a condition variable is used to
control execution of busy threads. It makes sure the busy thread can
only finish after dispatch_apply completes.

The dispatch_apply test sometimes fails in multicore machines.  The
failed function is test_apply_contended which tests if dispatch_apply
can make progress and finish with N concurrent busy threads running,
where N is the number of CPUs.  According to the testing log, it fails
because some busy threads already finish before dispatch_apply() is
invoked.

This happens because the test uses the ITERS_PER_SECOND variable to
control the number of iteration of the loop in the busy thread and
optimistically __hope__ the execution time is long enough to complete
the test. But sometimes this hope fails when the testing machine has
greater computing power and more CPU cores.

Instead of using ITERS_PER_SECOND, which makes an assumption about the
computing power of the test machine, a condition variable is used to
control execution of busy threads. It makes sure the busy thread can
only finish after dispatch_apply completes.
@MadCoder MadCoder merged commit 045f499 into swiftlang:master Jun 27, 2016
@chunchenhsu chunchenhsu deleted the modify_dispatch_test branch June 29, 2016 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants