SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
Ractor’s speed


is not light-speed.
Satoshi Tagomori (@tagomoris)
Satoshi Tagomori (@tagomoris)


a.k.a. Moris (モリス)


Freelance technical consultant (Aug 2021 ~)
Ractor


A new experimental feature


of Ruby 3.0


to run Ruby code in parallel on CPUs
Talks about Ractor in this Kaigi
• “Parallel testing with Ractors: putting CPUs to work”




by Vinicius Stock at Day 1


• “Ractor’s speed is not light-speed” (this talk)




by Satoshi Tagomori at Day 2


• “Ruby, Ractor, QUIC”




by Yusuke Nakamura at Day 3
Ractor’s Features
• Can run Ruby code of multiple Ractors in parallel on CPU cores


• by managing objects per Ractor


• Can move objects between Ractors


• Moved objects become invisible from the original Ractor


• Can share “shareable” objects between Ractors


• Modules, Classes


• Application code (Proc)


• De
fi
nitions (constants), Settings/Con
fi
gurations (frozen objects)


• …
What does “shareable” mean?
• Should be marked by Ractor.make_shareable(obj)


• will be frozen (in most cases)


• Proc: Ractor.make_shareable() makes Proc isolated


• “Isolated” Proc is not frozen, but shareable


• Proc#binding raises ArgumentError if it’s isolated


• All referred values (from the Proc) should be shareable too
Isolated Proc (1)
Isolated Proc (2)
Ractor:


The Feature for Speed
Question: How fast is Ruby w/ Ractor?
• xN faster if the laptop has N cpu cores?


• 8 cores on M1


• Is it true for Web applications?


• Is that faster than N processes by fork?


• Connection passing on memory (Ractor) vs RPC (fork)


• Does my webapp run faster w/ Ractor than the current deployment?
Needs: Experimental App Server using Ractor
• Rack application server


• Rack: protocol between server and application


• All servers are Rack server: webrick, unicorn, thin, puma, …


• Processing workers on Ractor


• Receive established connection, read request


• Run your Rack application


• Write response


• Speed: Appropriate performance, less overhead
light speed
light speed
right_speed
https:/
/github.com/tagomoris/right_speed
https:/
/rubygems.org/gems/right_speed
$ rackup -s right_speed config.ru


-O Host=127.0.0.1


-O Port=8080


-O Workers=12
Default # of workers is equal to # of CPUs
Demonstration


Running apps on right_speed


* Rack app


* Sinatra app


* Ruby on Rails app
https:/
/github.com/tagomoris/demo-webapps
Demonstration


Traffic


* single client connection + thread


* multiple client connections + threads
Problems about WebApps on Ractor
• SEGV at closing connections(?)


• Module/class instance variable accesses


• Accessing un-frozen (un-shareable) constants


• Dynamically de
fi
ned methods w/ un-shareable Proc
SEGV at closing connections (?)
• SEGV caused when it handles 2 (or more) connections


• bugs#18024
Module/Class Instance Variable Accesses
• Reading module/class instance variables causes Ractor::IsolationError


• Many frameworks (Rack, Sinatra, Rails) are heavily using it


• @var in the context of class << self


• for settings in many cases


• Used for default instance or default options (e.g., JSON.dump)


• Reading it will be allowed bugs#17592


• in the future (not
fi
xed yet)
Accessing Un-frozen/shareable Constants
• Constants can be accessible from Ractors, if deeply-frozen


• Use the magic comment always!




# frozen_string_literal: true


• Want a variant for Hash/Array (in my idea)




# frozen_shareable_constant_literal: true
define_method (1)
• Methods can be called in Ractor, usually


• Methods de
fi
ned by de
fi
ne_method may cause errors


• Blocks are unshareable!


• Frameworks (RoR/Sinatra/…) do this everywhere
define_method (2)
• Ractor-safe methods with shareable/isolated blocks


• Need shorthand!
Right Things to Be Done
• Applications: Check Ractor-safe or not


• Frameworks, libraries: Need many patches


• To make it Ractor-safe


• Ruby runtime: Make Ractor production ready


• More Ractor-safe core libraries


• More Ractor features (e.g, bugs#18139, etc)


• More features about productivity? (constant, proc, etc)
Thank you!

Mais conteúdo relacionado

Mais procurados

Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Igalia
 

Mais procurados (20)

How to distribute Ruby to the world
How to distribute Ruby to the worldHow to distribute Ruby to the world
How to distribute Ruby to the world
 
Developing high-performance network servers in Lisp
Developing high-performance network servers in LispDeveloping high-performance network servers in Lisp
Developing high-performance network servers in Lisp
 
Docker and Fluentd
Docker and FluentdDocker and Fluentd
Docker and Fluentd
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for Ruby
 
Gobblin on-aws
Gobblin on-awsGobblin on-aws
Gobblin on-aws
 
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
Building GUI App with Electron and Lisp
Building GUI App with Electron and LispBuilding GUI App with Electron and Lisp
Building GUI App with Electron and Lisp
 
The Future of Bundled Bundler
The Future of Bundled BundlerThe Future of Bundled Bundler
The Future of Bundled Bundler
 
Ruby in office time reboot
Ruby in office time rebootRuby in office time reboot
Ruby in office time reboot
 
Writing a fast HTTP parser
Writing a fast HTTP parserWriting a fast HTTP parser
Writing a fast HTTP parser
 
Pulsarctl & Pulsar Manager
Pulsarctl & Pulsar ManagerPulsarctl & Pulsar Manager
Pulsarctl & Pulsar Manager
 
[231] the simplicity of cluster apps with circuit
[231] the simplicity of cluster apps with circuit[231] the simplicity of cluster apps with circuit
[231] the simplicity of cluster apps with circuit
 
Ruby Security the Hard Way
Ruby Security the Hard WayRuby Security the Hard Way
Ruby Security the Hard Way
 
WTF is Twisted?
WTF is Twisted?WTF is Twisted?
WTF is Twisted?
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage libraryAn introduction and future of Ruby coverage library
An introduction and future of Ruby coverage library
 
Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015
 
JRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing WorldJRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing World
 
Leave end-to-end testing to Capybara
Leave end-to-end testing to CapybaraLeave end-to-end testing to Capybara
Leave end-to-end testing to Capybara
 

Semelhante a Ractor's speed is not light-speed

Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Nilesh Panchal
 
Ricardo Sanchez - Ruby projects of interest for devops
Ricardo Sanchez - Ruby projects of interest for devopsRicardo Sanchez - Ruby projects of interest for devops
Ricardo Sanchez - Ruby projects of interest for devops
SVDevOps
 
Ruby projects of interest for DevOps
Ruby projects of interest for DevOpsRuby projects of interest for DevOps
Ruby projects of interest for DevOps
Ricardo Sanchez
 
Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1
Sam Muhanguzi
 

Semelhante a Ractor's speed is not light-speed (20)

Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
 
Scala at Treasure Data
Scala at Treasure DataScala at Treasure Data
Scala at Treasure Data
 
Ricardo Sanchez - Ruby projects of interest for devops
Ricardo Sanchez - Ruby projects of interest for devopsRicardo Sanchez - Ruby projects of interest for devops
Ricardo Sanchez - Ruby projects of interest for devops
 
Ruby projects of interest for DevOps
Ruby projects of interest for DevOpsRuby projects of interest for DevOps
Ruby projects of interest for DevOps
 
Upgrading to rails3
Upgrading to rails3Upgrading to rails3
Upgrading to rails3
 
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmGenomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
 
Evented Ruby VS Node.js
Evented Ruby VS Node.jsEvented Ruby VS Node.js
Evented Ruby VS Node.js
 
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
 
DWX23 - Revolutionize Java DB AppDev with Reactive Streams and Virtual Threads
DWX23 - Revolutionize Java DB AppDev with Reactive Streams and Virtual ThreadsDWX23 - Revolutionize Java DB AppDev with Reactive Streams and Virtual Threads
DWX23 - Revolutionize Java DB AppDev with Reactive Streams and Virtual Threads
 
Hacking Java - Enhancing Java Code at Build or Runtime
Hacking Java - Enhancing Java Code at Build or RuntimeHacking Java - Enhancing Java Code at Build or Runtime
Hacking Java - Enhancing Java Code at Build or Runtime
 
Clustrix Database Percona Ruby on Rails benchmark
Clustrix Database Percona Ruby on Rails benchmarkClustrix Database Percona Ruby on Rails benchmark
Clustrix Database Percona Ruby on Rails benchmark
 
Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1
 
DEVNET-1106 Upcoming Services in OpenStack
DEVNET-1106	Upcoming Services in OpenStackDEVNET-1106	Upcoming Services in OpenStack
DEVNET-1106 Upcoming Services in OpenStack
 
Hacking Java @JavaLand2016
Hacking Java @JavaLand2016Hacking Java @JavaLand2016
Hacking Java @JavaLand2016
 
REACTIVE A New Hope!
REACTIVE A New Hope!REACTIVE A New Hope!
REACTIVE A New Hope!
 
MariaDB on Docker
MariaDB on DockerMariaDB on Docker
MariaDB on Docker
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
The Meteor Framework
The Meteor FrameworkThe Meteor Framework
The Meteor Framework
 
React.js at Cortex
React.js at CortexReact.js at Cortex
React.js at Cortex
 

Mais de SATOSHI TAGOMORI

Mais de SATOSHI TAGOMORI (20)

Good Things and Hard Things of SaaS Development/Operations
Good Things and Hard Things of SaaS Development/OperationsGood Things and Hard Things of SaaS Development/Operations
Good Things and Hard Things of SaaS Development/Operations
 
Maccro Strikes Back
Maccro Strikes BackMaccro Strikes Back
Maccro Strikes Back
 
Invitation to the dark side of Ruby
Invitation to the dark side of RubyInvitation to the dark side of Ruby
Invitation to the dark side of Ruby
 
Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)
 
Make Your Ruby Script Confusing
Make Your Ruby Script ConfusingMake Your Ruby Script Confusing
Make Your Ruby Script Confusing
 
Hijacking Ruby Syntax in Ruby
Hijacking Ruby Syntax in RubyHijacking Ruby Syntax in Ruby
Hijacking Ruby Syntax in Ruby
 
Lock, Concurrency and Throughput of Exclusive Operations
Lock, Concurrency and Throughput of Exclusive OperationsLock, Concurrency and Throughput of Exclusive Operations
Lock, Concurrency and Throughput of Exclusive Operations
 
Data Processing and Ruby in the World
Data Processing and Ruby in the WorldData Processing and Ruby in the World
Data Processing and Ruby in the World
 
Planet-scale Data Ingestion Pipeline: Bigdam
Planet-scale Data Ingestion Pipeline: BigdamPlanet-scale Data Ingestion Pipeline: Bigdam
Planet-scale Data Ingestion Pipeline: Bigdam
 
Technologies, Data Analytics Service and Enterprise Business
Technologies, Data Analytics Service and Enterprise BusinessTechnologies, Data Analytics Service and Enterprise Business
Technologies, Data Analytics Service and Enterprise Business
 
Ruby and Distributed Storage Systems
Ruby and Distributed Storage SystemsRuby and Distributed Storage Systems
Ruby and Distributed Storage Systems
 
Perfect Norikra 2nd Season
Perfect Norikra 2nd SeasonPerfect Norikra 2nd Season
Perfect Norikra 2nd Season
 
Fluentd 101
Fluentd 101Fluentd 101
Fluentd 101
 
To Have Own Data Analytics Platform, Or NOT To
To Have Own Data Analytics Platform, Or NOT ToTo Have Own Data Analytics Platform, Or NOT To
To Have Own Data Analytics Platform, Or NOT To
 
The Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and ContainersThe Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and Containers
 
How To Write Middleware In Ruby
How To Write Middleware In RubyHow To Write Middleware In Ruby
How To Write Middleware In Ruby
 
Modern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real WorldModern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real World
 
Open Source Software, Distributed Systems, Database as a Cloud Service
Open Source Software, Distributed Systems, Database as a Cloud ServiceOpen Source Software, Distributed Systems, Database as a Cloud Service
Open Source Software, Distributed Systems, Database as a Cloud Service
 
Fluentd Overview, Now and Then
Fluentd Overview, Now and ThenFluentd Overview, Now and Then
Fluentd Overview, Now and Then
 
How to Make Norikra Perfect
How to Make Norikra PerfectHow to Make Norikra Perfect
How to Make Norikra Perfect
 

Último

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Último (20)

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 

Ractor's speed is not light-speed

  • 1. Ractor’s speed is not light-speed. Satoshi Tagomori (@tagomoris)
  • 2. Satoshi Tagomori (@tagomoris) a.k.a. Moris (モリス) Freelance technical consultant (Aug 2021 ~)
  • 3.
  • 4. Ractor A new experimental feature of Ruby 3.0 to run Ruby code in parallel on CPUs
  • 5. Talks about Ractor in this Kaigi • “Parallel testing with Ractors: putting CPUs to work” 
 
 by Vinicius Stock at Day 1 
 • “Ractor’s speed is not light-speed” (this talk) 
 
 by Satoshi Tagomori at Day 2 
 • “Ruby, Ractor, QUIC” 
 
 by Yusuke Nakamura at Day 3
  • 6. Ractor’s Features • Can run Ruby code of multiple Ractors in parallel on CPU cores • by managing objects per Ractor • Can move objects between Ractors • Moved objects become invisible from the original Ractor • Can share “shareable” objects between Ractors • Modules, Classes • Application code (Proc) • De fi nitions (constants), Settings/Con fi gurations (frozen objects) • …
  • 7. What does “shareable” mean? • Should be marked by Ractor.make_shareable(obj) • will be frozen (in most cases) • Proc: Ractor.make_shareable() makes Proc isolated • “Isolated” Proc is not frozen, but shareable • Proc#binding raises ArgumentError if it’s isolated • All referred values (from the Proc) should be shareable too
  • 11. Question: How fast is Ruby w/ Ractor? • xN faster if the laptop has N cpu cores? • 8 cores on M1 • Is it true for Web applications? • Is that faster than N processes by fork? • Connection passing on memory (Ractor) vs RPC (fork) • Does my webapp run faster w/ Ractor than the current deployment?
  • 12. Needs: Experimental App Server using Ractor • Rack application server • Rack: protocol between server and application • All servers are Rack server: webrick, unicorn, thin, puma, … • Processing workers on Ractor • Receive established connection, read request • Run your Rack application • Write response • Speed: Appropriate performance, less overhead
  • 16. $ rackup -s right_speed config.ru -O Host=127.0.0.1 -O Port=8080 -O Workers=12 Default # of workers is equal to # of CPUs
  • 17. Demonstration Running apps on right_speed * Rack app * Sinatra app * Ruby on Rails app https:/ /github.com/tagomoris/demo-webapps
  • 18. Demonstration Traffic * single client connection + thread * multiple client connections + threads
  • 19. Problems about WebApps on Ractor • SEGV at closing connections(?) • Module/class instance variable accesses • Accessing un-frozen (un-shareable) constants • Dynamically de fi ned methods w/ un-shareable Proc
  • 20. SEGV at closing connections (?) • SEGV caused when it handles 2 (or more) connections • bugs#18024
  • 21. Module/Class Instance Variable Accesses • Reading module/class instance variables causes Ractor::IsolationError • Many frameworks (Rack, Sinatra, Rails) are heavily using it • @var in the context of class << self • for settings in many cases • Used for default instance or default options (e.g., JSON.dump) • Reading it will be allowed bugs#17592 • in the future (not fi xed yet)
  • 22. Accessing Un-frozen/shareable Constants • Constants can be accessible from Ractors, if deeply-frozen • Use the magic comment always! 
 
 # frozen_string_literal: true • Want a variant for Hash/Array (in my idea) 
 
 # frozen_shareable_constant_literal: true
  • 23. define_method (1) • Methods can be called in Ractor, usually • Methods de fi ned by de fi ne_method may cause errors • Blocks are unshareable! • Frameworks (RoR/Sinatra/…) do this everywhere
  • 24. define_method (2) • Ractor-safe methods with shareable/isolated blocks • Need shorthand!
  • 25. Right Things to Be Done • Applications: Check Ractor-safe or not 
 • Frameworks, libraries: Need many patches • To make it Ractor-safe 
 • Ruby runtime: Make Ractor production ready • More Ractor-safe core libraries • More Ractor features (e.g, bugs#18139, etc) • More features about productivity? (constant, proc, etc)