Ruby gvl-improvement at ruby 1.9.3
Upcoming SlideShare
Loading in...5
×
 

Ruby gvl-improvement at ruby 1.9.3

on

  • 11,368 views

ruby 1.9.3 でのGVLの改善について解説します

ruby 1.9.3 でのGVLの改善について解説します

Statistics

Views

Total Views
11,368
Views on SlideShare
7,004
Embed Views
4,364

Actions

Likes
11
Downloads
38
Comments
0

10 Embeds 4,364

http://mkosaki.blog46.fc2.com 4244
https://gitter.im 55
https://twitter.com 46
http://www.slideshare.net 8
http://twitter.com 4
http://www.linkedin.com 3
http://www.slashdocs.com 1
http://paper.li 1
http://s.deeeki.com 1
https://www.linkedin.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Ruby gvl-improvement at ruby 1.9.3 Ruby gvl-improvement at ruby 1.9.3 Presentation Transcript

  • Ruby 1.9.3 GVL FujitsuSunday, July 17, 2011
  • Who am I?Sunday, July 17, 2011
  • • • IO OS • usaSunday, July 17, 2011
  • at Linux Kernel Summit 2010Sunday, July 17, 2011
  • Shyouhei commiter ranking me!Sunday, July 17, 2011
  • Sunday, July 17, 2011
  • Sunday, July 17, 2011
  • GVLSunday, July 17, 2011
  • What’s GVL • Global(or Giant) VM Lock • • multi thread issue Ruby script • CPU • PythonSunday, July 17, 2011
  • What’s GVL (cont.) • GVL • GVL • OSSunday, July 17, 2011
  • f = false Thread.new { ....; f = true } Thread.pass until fSunday, July 17, 2011
  • GVL design • Lock wait (e.g. write) • lock, unlock Python, QEMU, Linux • GVL acquire/release pthread_mutex_{lock,unlock}Sunday, July 17, 2011
  • GVL design (cont.) • •Sunday, July 17, 2011
  • GVL design (cont.) • ON if (th->interrupt_flag) { gvl_release(); sched_yield(); gvl_acquire(); }Sunday, July 17, 2011
  • • OSS while (true) { ( ) lock(); if (hoge) { unlock(); break; • } unlock(); • thread lock rep_nop(); } hoge=1 lock(); hoge = 1; unlock();Sunday, July 17, 2011
  • Why?Sunday, July 17, 2011
  • CPU cpu1 cpu2 memory core core core core memory 1 2 core core core coreSunday, July 17, 2011
  • if (th->interrupt_flag) { gvl_release(); sched_yield(); gvl_acquire(); } •gvl_release() gvl_acquire() sched_yield() • sched_yield() yieldSunday, July 17, 2011
  • sched_yield • Unix API http://pubs.opengroup.org/onlinepubs/009695399/ functions/sched_yield.html int sched_yield(void); • The sched_yield() function shall force the running thread to relinquish the processor until it again becomes the head of its thread list. •Sunday, July 17, 2011
  • Thread core Thread Thread Thread Thread core Thread coreSunday, July 17, 2011
  • (ry CPU Thread core Thread Thread Thread core Thread Thread core ThreadSunday, July 17, 2011
  • Yield! Ruby Thread core Thread Thread core Ruby ThreadSunday, July 17, 2011
  • thread list head Thread core Ruby Thread Thread core Ruby ThreadSunday, July 17, 2011
  • Ruby Thread core Thread Thread core Ruby Thread POSIXSunday, July 17, 2011
  • CFS yield • Linux RHEL5 RHEL6 • RHEL6 (CFS) sched_yield (RHEL5 knob • Java • Linux upstream knob CPUSunday, July 17, 2011
  • • fairnessSunday, July 17, 2011
  • • fairness • GVL gvl_acquire gvl_release mutex_lock(&lock->lock) mutex_lock(&lock->lock) cond_wait(&lock->wait) lock->acquired = 0; lock->acquired = 1; cond_signal(&lock->wait_cond) // // cond_signal(&lock->switch_cond) cond_wait(&lock->switch_cond) mutex_unlock(&lock->lock) mutex_unlock(&lock->lock)Sunday, July 17, 2011
  • vm_thread_pipe lmax = 100_000 r, w = IO.pipe [Thread.new{ lmax.times{ w.write(a) } p "w:exit" }, Thread.new{ lmax.times{ r.read(1) } p "r:exit" }].each{|t| t.join}Sunday, July 17, 2011
  • (´ ω )Sunday, July 17, 2011
  • • fairness • unfairness • Linux •Sunday, July 17, 2011
  • 1.9.3 • 1.9.3 IO GVL release GVL release • IO GVL 1.9.2 IO GVL switch • GVL release switch GVL •Sunday, July 17, 2011
  • 1.9.2 1.9.3 2 1.5 1 0.5 0 create_join mutex1 mutex2 mutex3 pass_flood pipeSunday, July 17, 2011
  • • 1.9.2 • • •Sunday, July 17, 2011
  • vm_thread_mutex3Sunday, July 17, 2011
  • Sunday, July 17, 2011
  • • CPU • GVL CPU • RubySunday, July 17, 2011
  • Question?Sunday, July 17, 2011