]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: write much more direct test for semaphore waiter scalability
authorMichael Anthony Knyszek <mknyszek@google.com>
Thu, 16 Jun 2022 20:33:35 +0000 (20:33 +0000)
committerMichael Knyszek <mknyszek@google.com>
Thu, 16 Jun 2022 21:25:35 +0000 (21:25 +0000)
commit7bad61554ec6da4ba4cbad443074360408890603
treefd9df3023b65f581aeadb54ec0f2182cdb0c8851
parentf38a580a51cd2fc072aabc9dd45b9e0a85064c81
runtime: write much more direct test for semaphore waiter scalability

This test originally existed as two tests in test/locklinear.go, but
this checked against actual locks and was flaky. The test was checking
a property of a deep part of the runtime but from a much higher level,
and it's easy for nondeterminism due to scheduling to completely mess
that up, especially on an oversubscribed system.

That test was then moved to the sync package with a more rigorous
testing methodology, but it could still flake pretty easily.

Finally, this CL makes semtable more testable, exports it in
export_test.go, then writes a very direct scalability test for exactly
the situation the original test described. As far as I can tell, this is
much, much more stable, because it's single-threaded and is just
checking exactly the algorithm we need to check.

Don't bother trying to bring in a test that checks for O(log n) behavior
on the other kind of iteration. It'll be perpetually flaky because the
underlying data structure is a treap, so it's only _expected_ to be
O(log n), but it's very easy for it to get unlucky without a large
number of iterations that's too much for a simple test.

Fixes #53381.

Change-Id: Ia1cd2d2b0e36d552d5a8ae137077260a16016602
Reviewed-on: https://go-review.googlesource.com/c/go/+/412875
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/export_test.go
src/runtime/sema.go
src/runtime/sema_test.go
src/sync/mutex_test.go