1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test/ruby/test_thread.rb (test_thread_interrupt_for_killed_thread): conserve resources

Use Thread.pass to let the sub-thread finish.  This should avoid
running out of memory on resource-constrained systems.
(We don't want to use Thread#join to hit the exception)

This results in a significant memory usage reduction in this test:

  make test-all TESTS='../test/ruby/test_thread.rb -v -n test_thread_interrupt_for_killed_thread'

Before:

  3.46user 2.02system 0:05.29elapsed 103%CPU (0avgtext+0avgdata 88672maxresident)k
  0inputs+0outputs (0major+143071minor)pagefaults 0swaps

After:

  3.40user 1.83system 0:05.20elapsed 100%CPU (0avgtext+0avgdata 9368maxresident)k
  0inputs+0outputs (0major+3059minor)pagefaults 0swaps

cf. https://rubyci.org/logs/rubyci.s3.amazonaws.com/scw-9d6766/ruby-trunk/log/20180803T231706Z.fail.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2018-08-04 22:58:08 +00:00
parent 291a82f748
commit 80e973f0e6

View file

@ -1297,6 +1297,7 @@ q.pop
while true
t = Thread.new{sleep 0}
t.raise Interrupt
Thread.pass # allow t to finish
end
_end
end