[Bug:1.9] thread switch when heavy load


#1

e$B%^%7%s$NIi2Y$,9b$$$H$-$K!"%^%k%A%9%l%C%I%W%m%0%i%`$N=hM}$,?Je(B
e$B$^$J$$$3$H$,$"$j$^$9!#e(B

e$B0J2<$N%W%m%0%i%`$O%Q%$%W$Ke(B 1e$BICKh$Ke(B “a”
e$B$r=q$-9~$s$G!"$=$l$re(B
e$BB>$N%9%l%C%I$+$ie(B sysread e$B$GFI$=P$7$F!"FI$=P$7$K$+$+$C$?;~e(B
e$B4V$rI=<($9$k$b$N$G$9!#e(B

% cat /etc/debian_version
4.0
% uname -a
Linux nute 2.6.18-6-486 #1 Fri Dec 12 16:18:30 UTC 2008 i686 GNU/Linux
% ruby -ve ’
p $$
r, w = IO.pipe
Thread.new {
begin
t1 = Time.now
loop {
s = r.sysread(10)
t2 = Time.now
p [t2-t1, s]
t1 = t2
}
ensure
p $!
end
}
loop { w.write “a”; sleep 1 }

ruby 1.9.2dev (2009-02-15 trunk 22328) [i686-linux]
16259
[1.5086e-05, “a”]
[1.001370774, “a”]
[1.004141531, “a”]
[1.004539908, “a”]
[1.003810203, “a”]
[1.003755167, “a”]
[1.004224783, “a”]
[1.003889822, “a”]
[1.004372847, “a”]
[2.163765927, “a”]
[15.54612696, “a”]
[1.009049164, “a”]
[1.002022536, “a”]

e$B$3$3$G!"$@$$$?$$$OFI$_=P$7$Oe(B 1e$BIC$G9T$o$l$^$9!#$3$l$Oe(B
1e$BICKh$Ke(B
e$B=q$-9~$`$N$G4|BT$5$l$k5sF0$G$9!#e(B

e$B$7$+$7!"$R$H$De(B 15e$BIC0J>e$+$+$C$F$$$k$H$3$m$,$"$j$^$9!#e(B

e$B$3$l$O!"$3$N%?%$%_%s%0$GB>$NC<Kv$+$i0J2<$N$h$&$KIi2Y$r$+$1$?e(B
e$B7k2L$G$9!#e(B

% ruby -e ‘loop {}’

e$B$3$NIi2Y$re(B ^C e$B$G=*$o$i$;$?8e$O$U$D$&$K?J$_=P$7$^$9!#e(B

e$BIi2Y$r$+$1$?7k2L!">/$J$/$H$b=q$-9~$B&$N%9%l%C%I$N=hM}$,?J$^e(B
e$B$J$/$J$C$F$$$^$9!#e(B
(e$BFI$
=P$7B&$,;$^$C$F$$$k$N$G$J$$$3$H$O!“Ii2Y$r<h$j=|$$$?8ee(B
e$B$KI=<($5$l$ke(B “a” e$B$N?t$,$R$H$D$G$”$k$3$H$+$i$o$+$j$^$9!#$b$7e(B
e$BFI$
$@$7B&$@$1$,?J$^$J$/$J$C$F$$$k$N$G$"$l$P!"e(B15e$B8D$H$+$b$C$He(B
e$B$?$/$5$sI=<($5$l$k$O$:$G$9!#e(B)

e$B$=$l$J$i$J$K$r$7$F$s$N$+!"$H$$$&$3$H$Ge(B strace e$B$9$k$H!"e(B
e$B$/$j$+$($7e(B sched_yield() e$B$7$F$k$h$&$G$9!#e(B

% strace -p 16259
Process 16259 attached - interrupt to quit
sched_yield() = 0
sched_yield() = 0
sched_yield() = 0
sched_yield() = 0
sched_yield() = 0
sched_yield() = 0
sched_yield() = 0
sched_yield() = 0
sched_yield() = 0
sched_yield() = 0

e$B>/$J$/$H$b!"e(BOS e$B$,e(B ruby
e$B$K=hM}$r?J$a$k5!2q$r$^$C$?$/M?$($F$/e(B
e$B$l$J$$$H$$$&$o$1$G$O$J$$$h$&$G$9!#e(B

e$B$7$+$7<B:]$K$O=hM}$,?J$^$J$$$N$G$3$N5sF0$O4r$7$/$"$j$^$;$s!#e(B

e$B$G!“0J2<$N5?Ld$,$”$k$s$G$9$,!"$I$&$J$s$G$7$g$&$+!#e(B

  • e$B$3$N5sF0$O$I$Ne(B OS e$B$G5/$3$k$N$+e(B
  • ruby e$B$He(B GNU/Linux e$B$N$I$A$i$,LdBj$J$N$+e(B
    (e$B$"$k$$$ON>J}$+e(B)

e$B$"$H!"$3$3$G%F%9%H$7$?%^%7%s$O%7%s%0%k%W%m%;%C%5$G$9!#%^%k%Ae(B
e$B%W%m%;%C%5e(B (e$B%^%k%A%3%“e(B)
e$B$@$H!”:F8=$9$k$N$KIi2Y$rA}$d$9I,MW$,e(B
e$B$"$C$?$j$9$k$+$b$7$l$^$;$s!#e(B

e$B$J$*!"MF0W$KM=B,$5$l$k$3$H$G$9$,!“e(B1.8 e$B$G$OLdBj$”$j$^$;$s!#e(B