https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112011-09-19T17:25:58ZRuby Issue Tracking SystemBackport193 - Backport #5335: [RFC/PATCH] test_old_thread_select: timing tweakshttps://redmine.ruby-lang.org/issues/5335?journal_id=208942011-09-19T17:25:58Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul><li><strong>Assignee</strong> changed from <i>kosaki (Motohiro KOSAKI)</i> to <i>normalperson (Eric Wong)</i></li></ul><blockquote>
<p>diff --git a/test/-ext-/old_thread_select/test_old_thread_select.rb b/test/-ext-/old_thread_select/test_old_thread_select.rb<br>
index 1ccdb34..a8a0ce2 100644<br>
--- a/test/-ext-/old_thread_select/test_old_thread_select.rb<br>
+++ b/test/-ext-/old_thread_select/test_old_thread_select.rb<br>
@@ -16,10 +16,10 @@ class TestOldThreadSelect < Test::Unit::TestCase<br>
def test_old_select_read_timeout<br>
with_pipe do |r, w|<br>
t0 = Time.now</p>
<ul>
<li>
<pre><code> rc = IO.old_thread_select([r.fileno], nil, nil, 0.001)
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> rc = IO.old_thread_select([r.fileno], nil, nil, 0.01)
diff = Time.now - t0
assert_equal 0, rc
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> assert diff >= 0.001, "returned too early"
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> assert_operator diff, :>=, 0.004, "returned too early: diff=#{diff}"
</code></pre>
</li>
</ul>
</blockquote>
<p>No, I really dislike this. both 0.01 and 0.004 make no sense and no good reason we choose them.<br>
I guess 0.004 mean 250Hz. But in fact, only several linux systems use 250Hz. No platform independent meanings.</p>
<p>Instead, I just recommend to skip this test if platform is too old linux.<br>
(I guess our chkbuild caught the same issue, <a href="http://www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20110919T060500Z.log.html.gz" class="external">http://www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20110919T060500Z.log.html.gz</a>)</p>
<p>In addition, the correct way is, to detect inaccurate select timeout by configure script and do_select() retry to call select(2)<br>
automatically <em>if</em> we really need to care.</p> Backport193 - Backport #5335: [RFC/PATCH] test_old_thread_select: timing tweakshttps://redmine.ruby-lang.org/issues/5335?journal_id=208952011-09-19T18:10:59Znormalperson (Eric Wong)normalperson@yhbt.net
<ul><li><strong>File</strong> <a href="/attachments/2085">old_thread_select-skip-ancient-linux.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/2085/old_thread_select-skip-ancient-linux.patch">old_thread_select-skip-ancient-linux.patch</a> added</li></ul><p>While dynticks appeared in 2.6.21, I'm defining "ancient" as pre-2.6.32 since<br>
2.6.32 is still supported and widely deployed.</p>
<p>(having SSL troubles with redmine, apologies if you see this twice/thrice)</p> Backport193 - Backport #5335: [RFC/PATCH] test_old_thread_select: timing tweakshttps://redmine.ruby-lang.org/issues/5335?journal_id=208962011-09-19T18:23:21Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>Motohiro KOSAKI <a href="mailto:kosaki.motohiro@gmail.com" class="email">kosaki.motohiro@gmail.com</a> wrote:</p>
<blockquote>
<blockquote>
<p>diff --git a/test/-ext-/old_thread_select/test_old_thread_select.rb b/test/-ext-/old_thread_select/test_old_thread_select.rb<br>
index 1ccdb34..a8a0ce2 100644<br>
--- a/test/-ext-/old_thread_select/test_old_thread_select.rb<br>
+++ b/test/-ext-/old_thread_select/test_old_thread_select.rb<br>
@@ -16,10 +16,10 @@ class TestOldThreadSelect < Test::Unit::TestCase<br>
def test_old_select_read_timeout<br>
with_pipe do |r, w|<br>
t0 = Time.now</p>
<ul>
<li>
<pre><code> rc = IO.old_thread_select([r.fileno], nil, nil, 0.001)
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> rc = IO.old_thread_select([r.fileno], nil, nil, 0.01)
diff = Time.now - t0
assert_equal 0, rc
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> assert diff >= 0.001, "returned too early"
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> assert_operator diff, :>=, 0.004, "returned too early: diff=#{diff}"
</code></pre>
</li>
</ul>
</blockquote>
</blockquote>
<blockquote>
<p>No, I really dislike this. both 0.01 and 0.004 make no sense and no<br>
good reason we choose them. I guess 0.004 mean 250Hz. But in fact,<br>
only several linux systems use 250Hz. No platform independent<br>
meanings.</p>
</blockquote>
<p>Yes I used 0.004 to mean 250Hz. 250Hz is/was the default for a long<br>
time, but dynticks got introduced.</p>
<blockquote>
<p>Instead, I just recommend to skip this test if platform is too old linux.<br>
(I guess our chkbuild caught the same issue, <a href="http://www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20110919T060500Z.log.html.gz" class="external">http://www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20110919T060500Z.log.html.gz</a>)</p>
</blockquote>
<p>OK, new patch on the way.</p>
<blockquote>
<p>In addition, the correct way is, to detect inaccurate select timeout<br>
by configure script and do_select() retry to call select(2)<br>
automatically <em>if</em> we really need to care.</p>
</blockquote>
<p>I don't care enough for this, too much effort for an old platform.</p> Backport193 - Backport #5335: [RFC/PATCH] test_old_thread_select: timing tweakshttps://redmine.ruby-lang.org/issues/5335?journal_id=208972011-09-19T18:47:29Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r33296.<br>
Eric, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<ul>
<li>test/-ext-/old_thread_select/test_old_thread_select.rb:<br>
select() with timeout may return early in old Linux kernels<br>
with 250 Hz tickrate and no dynticks, so skip everything older<br>
than 2.6.32 (which has long term support).<br>
And, Make the timing assertions consistently use assert_operator with<br>
timing difference in error message<br>
Patch by Eric Wong. [Bug <a class="issue tracker-4 status-5 priority-4 priority-default closed" title="Backport: [RFC/PATCH] test_old_thread_select: timing tweaks (Closed)" href="https://redmine.ruby-lang.org/issues/5335">#5335</a>] <a href="/issues/5335">[ruby-core:39618]</a></li>
</ul> Backport193 - Backport #5335: [RFC/PATCH] test_old_thread_select: timing tweakshttps://redmine.ruby-lang.org/issues/5335?journal_id=208982011-09-19T18:51:02Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul><li><strong>Tracker</strong> changed from <i>Bug</i> to <i>Backport</i></li><li><strong>Project</strong> changed from <i>Ruby master</i> to <i>Backport193</i></li><li><strong>Category</strong> deleted (<del><i>core</i></del>)</li><li><strong>Status</strong> changed from <i>Closed</i> to <i>Assigned</i></li><li><strong>Assignee</strong> changed from <i>normalperson (Eric Wong)</i> to <i>kosaki (Motohiro KOSAKI)</i></li><li><strong>Target version</strong> deleted (<del><i>1.9.3</i></del>)</li></ul><p>I've commited this one to trunk only. I'm watching what's happen boron chkbuild.</p>
<p>Thank you.</p> Backport193 - Backport #5335: [RFC/PATCH] test_old_thread_select: timing tweakshttps://redmine.ruby-lang.org/issues/5335?journal_id=212792011-10-11T11:33:35Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>This issue was solved with changeset r33456.<br>
Eric, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<p>merge revision(s) 33296:</p>
<pre><code>* test/-ext-/old_thread_select/test_old_thread_select.rb:
select() with timeout may return early in old Linux kernels
with 250 Hz tickrate and no dynticks, so skip everything older
than 2.6.32 (which has long term support).
And, Make the timing assertions consistently use assert_operator with
timing difference in error message
Patch by Eric Wong. [Bug #5335] <a href="/issues/5335">[ruby-core:39618]</a>
</code></pre> Backport193 - Backport #5335: [RFC/PATCH] test_old_thread_select: timing tweakshttps://redmine.ruby-lang.org/issues/5335?journal_id=212802011-10-11T11:35:07Zkosaki (Motohiro KOSAKI)kosaki.motohiro@gmail.com
<ul></ul><p>Done.<br>
r33454 and r33456.</p>