Skip to content

Commit c302137

Browse files
author
Fabien Coelho
committed
remove one barrier and explain hit rate instability
1 parent 49c12fd commit c302137

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ def run():
670670
barrier.wait()
671671
for s in ls:
672672
for n in li:
673-
barrier.wait()
673+
# barrier.wait()
674674
assert banged(s, n) == s * n + "!"
675675
barrier.wait()
676676
log.debug(f"thread end: {name}")
@@ -684,7 +684,9 @@ def run():
684684
assert len(cache) == 32
685685
# 16 * 2 gets-no-hit + 16 * (nthreads - 1) get-with-hit
686686
hits = (nthreads - 1) / (nthreads + 1)
687-
# NOTE hit ratio is not deterministic
687+
# NOTE hit ratio is not deterministic: two thread may "get" at the same
688+
# time, intercept the missing exception, compute the value and "set" it in cache.
689+
# the failed "get" does not keep the lock to prevent that.
688690
assert 0.75 * hits < cache.hits() <= hits
689691

690692
def test_threads():

0 commit comments

Comments
 (0)