Gvl改善案

$B>.:j$G$9(B

$BBg7?O"5Y$N$5$J$+!"$_$J$5$sG!2?$*2a$4$7$G$7$g$&$+!#$o$?$7$O855$$G$9!#$4$U$C(B

$B$($C$H!“0JA0$+$i;XE&$5$l$F$$$?;v$G$9$,!“8=:_$N(Btrunk$B$N(BGVL$B<[email protected]$H(B1.9.2$B$h$j$b(B
$B$”$k<o$N%Y%s%A$,CY$/$J$C$F$^$9!#$0$?$$$F$-$K$O!”(Bpipe$B$d(BThread.pass$B$G#2$D$N%9%l%C%I$,(B
$B%.%C%3%s%P%C%?%s$9$k%1!<%9$G$9$M!#(B

    simple-mutex  r31433

vm4_pipe 1.262 2.495
vm4_thread_pass 0.183 2.034

$B$J$N$G!"JL<BAu$r$D$/$C$F$_$^$7$?!#0J2<$N$h$&$K$J$j$^$9!#(B

    simple-mutex  r31433  newgvl

vm4_pipe 1.262 2.495 1.493
vm4_thread_pass 0.183 2.034 0.089

$B%Q%C%A$O0J2<$G$9(B

$BE:IU$7$?%U%!%$%k$N$&$A!"(Bbm.txt$B$,85%G!<%?!J(BCSV)$B$G!"@-G=%0%i%U(B.png$B$,%(%/%;%k$5$s$,(B
$B:n$C$F$/$l$?%0%i%U$G$9!#(B
$B0l3d0J>[email protected]=$,$+$o$C$?%Y%s%A$r%T%C%/%"%C%W$9$k$H0J2<(B

                            r31433     newgvl        ratio 

(1$B0J2<$J$i9bB.!K(B
so_sieve 1.642 1.43 0.87088916
vm1_ivar_set* 1.401 1.647 1.175588865
vm3_thread_mutex 17.083 1.168 0.068372066
vm4_pipe 2.495 1.493 0.598396794
vm4_thread_pass 2.034 0.089 0.043756146

$BA4BN$N%"%Y%l!<%8$G$O!"(B1.3%
$BDxEY$N2~A1$H$$$C$?$H$3$m$G$9!#%3%a%s%HBT$C$F$^$9(B
$B"((B [email protected]>[email protected]$&$H(B vm1_ivar_set
$B$,D>$;$J$/$F:$$C$F$$$k$N$GC/$+=u$1$F$/[email protected]$5$$$^$;(B

$B8D?ME*$K$O!"(Bvm3_thread_mutex$B$,$d$C$H(B1.8$B$J$_$KLa$C$F$/$l$?$N$GC#@.46$,(B
$B$"$C$?$j$J$+$C$?$j!#(B

                            1.8.7      r31433      newgvl

vm3_thread_mutex 1.106 17.083 1.168

$B$"$H!“46A[$H$7$F$O(B
benchmark$B%G%#%l%/%H%j$NBgH>$N%Y%s%A%^!<%/$O(Bthread$B$D$/$i$J$$$s$G$9$,!”(B
$B6%9g$,$J$$$H2>Dj$9$k$H(B1.9.2$B$N(Bsimple
mutex$B:G6/$G$9$M!#2?$b$7$J$$$N$,B.$$$K$-$^$C$H$k!#(B
$B:#$NJ}?K$G!"$3$l0J>e$d$k$J$i!"%"%;%s%V%i=q$$$F(Bfutex$B$rD>@\C!$/$H$+$=$&[email protected]$3&$,$^$C$F$k$N$G!"(B
$B<!$N0l<j$r$I$&$7$h$&$+$J$!!#$H$+$H$+(B

kosaki $B$G$9(B

$B$b$&$A$g$C$H!"$3$N%M%?$R$C$Q$j$^$9!#(B

$B$"$H!"$7$P$i$/A0$+$iJ,$+$C$F$O$$$?$s$G$9$,!"8=:$N(Btrunk$B$N(BGVL$B$O(B1.9.2$B$h$j$bCY$$$N$K(B
fairness
issue$B$,2r7h$7$F$J$$$H$$$&LdBj$,$"$j!"6qBNE*$K$O:G6a(Bnakada$B$5$s$,(B
8core$B%^%7%s$G(B make test-all
$B$,%O%s%0$9$k$H$$$&8=>]$KAx6x$7$F0J2<$N%Q%C%A$r(B
$B%3%
%C%H$5$l$^$7$?!#(B

$BFC$K(B Core i7 $B$_$?$$$J(BP2P$B$J%-%c%C%7%[email protected]$G(B

0 until hogehoge

$B$_$?$$$J%S%8!<%k!<%W=q$/$H%O%^$k$N$G!"$3$l$r!VD>$9$Y$-!W$H$9$k$+!"(B
[email protected];[email protected]!"%f!<%6$O5$$r$D$1$F%9%/%j%W%H=q$-$d$,$l!W$H$9$k$+7h$a$J$$$H(B
$B$$$1$J$$!#$H$+$H$+(B

commit 21fcb1c3a19bf6b330aebf14f4c915c0d63925d6
Author: nobu [email protected]
Date: Sat May 7 14:52:54 2011 +0000

* test/ruby/test_io.rb (TestIO#test_readpartial_lock),
  (TestIO#test_read_lock): get rid of GVL fairness problem.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/[email protected]

b2dd03c8-39d4-4d8f-98ff-823fe69b080e

diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 07308a0…9171dc6 100644
— a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -904,7 +904,7 @@ class TestIO < Test::Unit::TestCase
with_pipe do |r, w|
s = “”
t = Thread.new { r.readpartial(5, s) }

  •  0 until s.size == 5
    
  •  Thread.pass until s.size == 5
     assert_raise(RuntimeError) { s.clear }
     w.write "foobarbaz"
     w.close
    

@@ -939,7 +939,7 @@ class TestIO < Test::Unit::TestCase
with_pipe do |r, w|
s = “”
t = Thread.new { r.read(5, s) }

  •  0 until s.size == 5
    
  •  Thread.pass until s.size == 5
     assert_raise(RuntimeError) { s.clear }
     w.write "foobarbaz"
     w.close

(2011/05/08 21:10), KOSAKI Motohiro wrote:

$B$_$?$$$J%S%8!<%k!<%W=q$/$H%O%^$k$N$G!"$3$l$r!VD>$9$Y$-!W$H$9$k$+!"(B
[email protected];[email protected]!"%f!<%6$O5$$r$D$1$F%9%/%j%W%H=q$-$d$,$l!W$H$9$k$+7h$a$J$$$H(B
$B$$$1$J$$!#$H$+$H$+(B

$B$=$&$$$&%3!<%I$O$h$/=q$/$N$G!"DL$C$F$/$l$?J}$,$&$l$7$$$G$9$M$’!#(B

$B$^$D$b$H(B $B$f$-$R$m$G$9(B

In message “Re: [ruby-dev:43469] Re: GVL$B2~A10F(B”
on Sun, 8 May 2011 21:10:03 +0900, KOSAKI Motohiro
[email protected] writes:

|0 until hogehoge
|
|$B$_$?$$$J%S%8!<%k!<%W=q$/$H%O%^$k$N$G!"$3$l$r!VD>$9$Y$-!W$H$9$k$+!"(B
|[email protected];[email protected]!"%f!<%6$O5$$r$D$1$F%9%/%j%W%H=q$-$d$,$l!W$H$9$k$+7h$a$J$$$H(B
|$B$$$1$J$$!#$H$+$H$+(B

$B!VD>$9$Y$-!W$G$7$g$&!#(B

$B$3$s$K$A$O!"$J$+$`$i(B($B$&(B)$B$G$9!#(B

In message “[ruby-dev:43483] Re: GVL$B2~A10F(B”
on May.09,2011 07:19:30, [email protected] wrote:

|0 until hogehoge
|
|$B$_$?$$$J%S%8!<%k!<%W=q$/$H%O%^$k$N$G!"$3$l$r!VD>$9$Y$-!W$H$9$k$+!"(B
|[email protected];[email protected]!"%f!<%6$O5$$r$D$1$F%9%/%j%W%H=q$-$d$,$l!W$H$9$k$+7h$a$J$$$H(B
|$B$$$1$J$$!#$H$+$H$+(B

$B!VD>$9$Y$-!W$G$7$g$&!#(B

$B$$$-$J$j(B10$B%v7n$/$i$$A0$N%M%?$r>x$7JV$7$^$9$1$I!"$=$N8e(Br32064
$B$G3:Ev%3!<%I$,F~$l$i$l$F!"0J9_$O(B250ms($B<B:]$O(B100ms$BC10L$G$7$+H=(B
$BDj$5$l$J$$$N$G(B300ms)$B$K0lEY$7$+%9%l%C%I$,@Z$jBX$o$i$J$/$J$C$F(B
$B$$$^$9!#(B

[email protected]$H$3$s$J46$8!#(B
ruby -e 'Thread.new{loop{}}; loop{p Time.now.usec; Thread.pass}

ruby-core$B$G$O>^6b$^$G$+$1$i$l$F$^$9$,(B([ruby-core:42972])$B!"$:(B
$B$P$j$3$l$,860x$G$9!#(B

$B$=$l$G$O!#(B

$B$3$s$K$A$O!"$J$+$`$i(B($B$&(B)$B$G$9!#(B

In message “[ruby-dev:45300] Re: GVL$B2~A10F(B”
on Mar.01,2012 06:35:56, [email protected] wrote:

usa$B$5$s$H([email protected]$7$?$s$G$9$,!"JRJ}$,(Bbusy loop $B$GJRJ}$,(B

Thread.pass$B$G?B;NE*$K?6$kIq$C$?>l9g!"$^$C$H$&$J%$%s%W%j$G$"$k8B$j$I$&<BAu$7$F$b(Bbusy
loop$B$,K=$l$k$s$8$c$J$$$G$9$+$M!#(B

time slice$B$rC;$/$9$l$P8=>]$,8+$($K$/$/$J$k$1$I$=$l$,2r$J$N$+$J$"(B

$B;DG0$J$3$H$K(Btk$B$N%3!<%I$C$F$?$^$K(BThread.pass$B$G>y$k$1$I!"%$%Y%s%H$J$$;~$G$b(Bbusy

loop$B$7$D$E$1$k$h$&$J$N$G!"(Btk$B$N%$%Y%s%H%9%l%C%I$K(BCPU$B$rM%@hE*$K3d$jEv$F$k%!<%J%9$r<BAu$9$k$H!"$3$s$I$O%P%C%/%0%i%&%s%I=hM}$N$[$&$,$^$C$?$/F0$+$J$/$J$j$=$&(B

$BIU$12C$($k$H!"(B

(1)
$B%$%Y%s%H%k!<%W$O(BGVL$B30$7$F2s$7!"%$%Y%s%H$KBP1~$9$k(Bruby$B%3(B
$B!<%I$r<B9T$9$k$H$-$K2~$a$F(BGVL$B$r<[email protected]$9$Y$-$G$O$J$$$+!#(B

(2)
(1)$B$G$N(BGVL$B<[email protected]$G:G0-(B300ms$BBT$?$5$l$k$H7k6IF1$8$3$H$J$N$G!"(B
$B2?$i$+$N7A$GM%@hE*$K(BGVL$B$r<[email protected]$G$-$k$h$&$J(BAPI$B$,$"$k$H$$(B
$B$$$N$G$O$J$$$+!#(B

$B$H$$$&%"%$%G%"$O=P$F$$$^$7$?!#(B
(2)$B$K$D$$$F$O!"%9%l%C%I$N(Bpriority$B$HF1$80UL#$NCM$r0z?t$K<h$k$h(B
$B$&$J(BAPI$B$K$7$F!":#F0$$$F$k%9%l%C%I$N(Bpriority$B$h$j0z?t$N(Bpriority
$B$NJ}$,9b$$>l9g$O(BGVL$BC%$C$A$c$&!"$H$$$&$N$G$I$&[email protected]$m$&!"$H;d$O>!(B
$B<j$K9M$($F$$$^$9!#(B

$B$=$l$G$O!#(B

[email protected]$H$3$s$J46$8!#(B
ruby -e 'Thread.new{loop{}}; loop{p Time.now.usec; Thread.pass}

ruby-core$B$G$O>^6b$^$G$+$1$i$l$F$^$9$,(B([ruby-core:42972])$B!"$:(B
$B$P$j$3$l$,860x$G$9!#(B

usa$B$5$s$H([email protected]$7$?$s$G$9$,!“JRJ}$,(Bbusy loop
$B$GJRJ}$,(B
Thread.pass$B$G?B;NE*$K?6$kIq$C$?>l9g!”$^$C$H$&$J%$%s%W%j$G$"$k8B$j$I$&<BAu$7$F$b(Bbusy
loop$B$,K=$l$k$s$8$c$J$$$G$9$+$M!#(B

time slice$B$rC;$/$9$l$P8=>]$,8+$($K$/$/$J$k$1$I$=$l$,2r$J$N$+$J$"(B

$B;DG0$J$3$H$K(Btk$B$N%3!<%I$C$F$?$^$K(BThread.pass$B$G>y$k$1$I!"%$%Y%s%H$J$$;~$G$b(Bbusy
loop$B$7$D$E$1$k$h$&$J$N$G!"(Btk$B$N%$%Y%s%H%9%l%C%I$K(BCPU$B$rM%@hE*$K3d$jEv$F$k%!<%J%9$r<BAu$9$k$H!"$3$s$I$O%P%C%/%0%i%&%s%I=hM}$N$[$&$,$^$C$?$/F0$+$J$/$J$j$=$&(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs