Project

General

Profile

Actions

Bug #1820

closed

Always spawns a thread that loops on the futex syscall

Added by mxey (Maximilian Gass) over 15 years ago. Updated over 13 years ago.

Status:
Rejected
Assignee:
-
ruby -v:
ruby 1.9.1p0 (2009-01-30 revision 21907) [x86_64-linux]
[ruby-core:24576]

Description

=begin
Starting with Ruby 1.9, every Ruby process starts two threads.
One of these is looping on the futex syscall all the time.
I have attached an strace log of irb.

Ruby 1.9.0 had the same problem, but it was a different syscall.

I tested this on Debian GNU/Linux, but the problem also existed on Gentoo Linux.
It still exists with the recent Ruby 1.9.2 preview release:
=end


Files

strace.out (114 KB) strace.out mxey (Maximilian Gass), 07/28/2009 04:12 AM
Actions #1

Updated by rogerdpack (Roger Pack) almost 15 years ago

  • Status changed from Open to Rejected

=begin
I think this is expected since it spawn one thread to just handle incoming signals. If it's not then please reopen.
-r
=end

Actions #2

Updated by mxey (Maximilian Gass) almost 15 years ago

=begin
I see no problem with spawning an extra thread to handle signals. But if that is true, the extra thread should actually wait for a signal using the pause() syscall instead of looping continously.
=end

Actions #3

Updated by rogerdpack (Roger Pack) almost 15 years ago

=begin
Is it using 100% of one core?

With my irb (ubuntu), 1.9.1p376 here's my strace without entering the key "3" and hitting enter:

http://pastie.org/809883

It seems to not be looping (if at all).

With windows (ruby -e 'sleep')
I get this trace (repeated about 100x/s)

[T4252] WaitForSingleObject(798, a, 80502f6a, b34b2ca0, ...) = 102
[T4252] WaitForSingleObject(798, a, 80502f6a, b34b2ca0, ...) = 102
[T4252] WaitForSingleObject(798, a, 80502f6a, b34b2ca0, ...) = 102

Which I think is just the signal thread waking up and then going back to sleep, and appears to use 0% cpu.

What version of readline do you have? Is yours more frequent than this?

Thanks.
-r
=end

Actions #4

Updated by mxey (Maximilian Gass) almost 15 years ago

=begin
It is not using 100% of one core, not at all. But it causes frequent wakeups that prevent the CPU from going to sleep. I first stumbled upon this by using powertop.

Did you run strace with -f to follow the extra thread it creates? Otherwise you will just attach to the first one and not notice the other one.

I doubt the problem is related to readline at all. The looping also happens when you run just ruby instead of irb.
=end

Actions #5

Updated by rogerdpack (Roger Pack) almost 15 years ago

  • Status changed from Rejected to Open

=begin
ahh it appears to also wake up once every 10ms in linux.
Anybody know if this is avoidable by using pause(), as Maximilian suggests?
-rp
=end

Actions #6

Updated by mame (Yusuke Endoh) over 14 years ago

  • Status changed from Open to Rejected

=begin
Hi,

That is the timer thread which triggers context switch of Ruby-level
threads. Thus, this is not a bug. I close the ticket.

There may be some optimization to remove the thread, but I have no
concrete idea. If you have, please register it into Feature tracker.

--
Yusuke Endoh
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0