SlideShare a Scribd company logo
1 of 28
Download to read offline
Lourens Naudé, Trade2Win


Inside Matz Ruby
High level Ruby internals crash
course.
Bio
   http://github.com/methodmissing
       Ruby contractor
       Currently building out a consumer forex platform @ Trade2Win.
   creator
       scrooge, mysqlplus_adapter, mri_instrumentation
   contributor
       Rails, mysqlplus, query_memcached, thinking-sphinx,
        em-spec
def users_of( :ruby )
 frequently()
 raise Opinion
rescue
 next_slide.call()
end
Have you looked at
   the source ?
Mere mortal, with a toolbox
   Basic C skills *
   Understanding of the UNIX subsystem *
   Dtrace *
   GDB *
   GCC macro expansion *
   Add preferred insomnia beverage
   * RTFM
The Symbol Table
   Generic hash implementation – bins && items
   Inits with 11 bins, > 5 items per bin spawns more
    for optimal density
   Table.has_many :bins
   Bin.has_maby :symbol_table_entries
   Strings or numbers as hash keys
   Global vars and classes stored in number table
   Collisions do happen … expensive
Values and identifiers
   VALUE and ID is an unsigned long
   Special types eg. true, false, nil directly
    represented by a VALUE … immediates
   The infamous nil with ID 4: #define Qnil 4
   struct RBasic {
       unsigned long flags;
       VALUE klass;
      };
Types
   One per builtin type : Array, Symbol etc.
   Special hidden types
       Mixed in modules
       Syntax tree nodes
       Variable scope
Casting Values
   Immediates ( nil ) looked up first for efficiency
   ROBJECT(123343434) → T_ARRAY
Type Flags
   Singleton class ?
   Marked for GC ?
   Tainted ?
   Any finalizers defined ?
   Instance variables defined on the object ?
   Frozen ?
Classes
 Instance variables + method table
 Super member
 Only for Kernel, class->super == NULL
 Array->super == Object
Objects
 Instance var table
 Object#method
       Searches the method table of it's class
       Fallback to superclass on 404
   Method cache busted when
       MyClass.send( :extend, OtherModule )
Method Inclusion
 class A
    include B
  end
 Included class : internal type for module
  mixins
 Pointer to the same ivar && method table
Hash
   Based on the symbol tables
       Iteration, insertion && removal
   Iteration level
       Track, and act upon, any changes during loops
   Mixed in modules
String
   Min. buffer size is 128 bytes
       's' occupies 128 – sizeof('s')
   static const char null_str[] = quot;quot;;
       New strings point to null_str for efficiency
   Locking mechanism
       String#gsub
       IO.read && IO#sysread buffers
Array
   Default capacity of 16 elements
       [x] occupies sizeof( 16 of x ) – sizeof(x)
   Locking mechanism
       Array#sort(!)
Preallocation
   Arrays and strings
       Similar structure : length && ptr members
 An initial and expandable capacity
 Slightly more space allocated to avoid
  reallocation overheads
 Supports sharing of values, where possible
Blocks
 Snapshots
 Optional arguments + a body
 Persistent local scope
 Linkable
       block->prev for iterators
Frames
   An item on the method call stack
   Arguments count and values
   Receiver state eg. AClass#method_invoked
   Links back to the previous frame
   Node state
Threads
 SIGVTALRM signal reserved
 Virtual ring through th->prev && th->next
 Evenly timesliced @ 10ms
 Threads can block for
       A single file descriptor
       A select operation
       Thread.join && Thread#value
Garbage Collection
   Process.has_many :heaps
       Where objects are stored
       Heap.has_many :slots


   Heap space maxed
       GC runs to free some space
       Allocates a new heap * 1.8 bigger
GC – Entries
   Entries
       Wraps core classes, nodes, scope etc.
   Reference values
       Flags + pointer to the next value
   Freelist is special global reference value
GC – Allocation and deallocation
   Object deallocation
       Immediates ignored
       Class frees method table, File close it's descriptor etc.
   New object allocation
       Force GC if no freelist
       Reference value assigned from the freelist
       Freelist updated to reflect the next free value
GC – Mark phase
   Object references it's klass, members etc.
       Module marks it's methods and ivar table
 Ignores immediates
 Each object recursively marks others
 Sets the marked flag for reference values
 Applicable to
       Global vars
       Variables currently on the stack
GC – Sweep phase
 Iterates through all objects
 Deletes objects not previously marked
 Defers sweeping if finalizer registered
Questions ?
Follow methodmissing @
github or twitter.Thanks!

More Related Content

What's hot

JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - OperatorsWebStackAcademy
 
Javascript session 01 - Introduction to Javascript
Javascript session 01 - Introduction to JavascriptJavascript session 01 - Introduction to Javascript
Javascript session 01 - Introduction to JavascriptLivingston Samuel
 
Fazendo mágica com ElasticSearch
Fazendo mágica com ElasticSearchFazendo mágica com ElasticSearch
Fazendo mágica com ElasticSearchPedro Franceschi
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsOWASP Kyiv
 
Learn Ajax here
Learn Ajax hereLearn Ajax here
Learn Ajax herejarnail
 
Squeak DBX
Squeak DBXSqueak DBX
Squeak DBXESUG
 
In Pursuit of the Grand Unified Template
In Pursuit of the Grand Unified TemplateIn Pursuit of the Grand Unified Template
In Pursuit of the Grand Unified Templatehannonhill
 
Jackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSVJackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSVTatu Saloranta
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101ygv2000
 
Scala for scripting
Scala for scriptingScala for scripting
Scala for scriptingmichid
 
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...DataStax
 
Simple Jackson with DropWizard
Simple Jackson with DropWizardSimple Jackson with DropWizard
Simple Jackson with DropWizardTatu Saloranta
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions WebStackAcademy
 
JavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft TrainingJavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft TrainingRadoslav Georgiev
 
How and Where in GLORP
How and Where in GLORPHow and Where in GLORP
How and Where in GLORPESUG
 
Cutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryCutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryWilliam Candillon
 

What's hot (20)

JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
 
Javascript session 01 - Introduction to Javascript
Javascript session 01 - Introduction to JavascriptJavascript session 01 - Introduction to Javascript
Javascript session 01 - Introduction to Javascript
 
Slickdemo
SlickdemoSlickdemo
Slickdemo
 
Fazendo mágica com ElasticSearch
Fazendo mágica com ElasticSearchFazendo mágica com ElasticSearch
Fazendo mágica com ElasticSearch
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tips
 
Learn Ajax here
Learn Ajax hereLearn Ajax here
Learn Ajax here
 
Squeak DBX
Squeak DBXSqueak DBX
Squeak DBX
 
In Pursuit of the Grand Unified Template
In Pursuit of the Grand Unified TemplateIn Pursuit of the Grand Unified Template
In Pursuit of the Grand Unified Template
 
Jackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSVJackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSV
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
 
Scala for scripting
Scala for scriptingScala for scripting
Scala for scripting
 
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
 
Simple Jackson with DropWizard
Simple Jackson with DropWizardSimple Jackson with DropWizard
Simple Jackson with DropWizard
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 
JavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft TrainingJavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft Training
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
How and Where in GLORP
How and Where in GLORPHow and Where in GLORP
How and Where in GLORP
 
Lec 7
Lec 7Lec 7
Lec 7
 
Cutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryCutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQuery
 
Sql killedserver
Sql killedserverSql killedserver
Sql killedserver
 

Similar to Railswaycon Inside Matz Ruby

Cassandra Talk: Austin JUG
Cassandra Talk: Austin JUGCassandra Talk: Austin JUG
Cassandra Talk: Austin JUGStu Hood
 
On Rails with Apache Cassandra
On Rails with Apache CassandraOn Rails with Apache Cassandra
On Rails with Apache CassandraStu Hood
 
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016DataStax
 
Glorp Tutorial Guide
Glorp Tutorial GuideGlorp Tutorial Guide
Glorp Tutorial GuideESUG
 
Cassandra: Open Source Bigtable + Dynamo
Cassandra: Open Source Bigtable + DynamoCassandra: Open Source Bigtable + Dynamo
Cassandra: Open Source Bigtable + Dynamojbellis
 
Barcamp Auckland Rails3 presentation
Barcamp Auckland Rails3 presentationBarcamp Auckland Rails3 presentation
Barcamp Auckland Rails3 presentationSociable
 
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...Maarten Balliauw
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHPRob Knight
 
mongodb-aggregation-may-2012
mongodb-aggregation-may-2012mongodb-aggregation-may-2012
mongodb-aggregation-may-2012Chris Westin
 
Java Script
Java ScriptJava Script
Java ScriptSarvan15
 
Java Script
Java ScriptJava Script
Java ScriptSarvan15
 
Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016takezoe
 

Similar to Railswaycon Inside Matz Ruby (20)

Cassandra Talk: Austin JUG
Cassandra Talk: Austin JUGCassandra Talk: Austin JUG
Cassandra Talk: Austin JUG
 
70 536
70 53670 536
70 536
 
On Rails with Apache Cassandra
On Rails with Apache CassandraOn Rails with Apache Cassandra
On Rails with Apache Cassandra
 
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
 
Glorp Tutorial Guide
Glorp Tutorial GuideGlorp Tutorial Guide
Glorp Tutorial Guide
 
Workin On The Rails Road
Workin On The Rails RoadWorkin On The Rails Road
Workin On The Rails Road
 
Qure Tech Presentation
Qure Tech PresentationQure Tech Presentation
Qure Tech Presentation
 
Cassandra: Open Source Bigtable + Dynamo
Cassandra: Open Source Bigtable + DynamoCassandra: Open Source Bigtable + Dynamo
Cassandra: Open Source Bigtable + Dynamo
 
Meta Object Protocols
Meta Object ProtocolsMeta Object Protocols
Meta Object Protocols
 
Barcamp Auckland Rails3 presentation
Barcamp Auckland Rails3 presentationBarcamp Auckland Rails3 presentation
Barcamp Auckland Rails3 presentation
 
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
 
JPA and Hibernate
JPA and HibernateJPA and Hibernate
JPA and Hibernate
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHP
 
mongodb-aggregation-may-2012
mongodb-aggregation-may-2012mongodb-aggregation-may-2012
mongodb-aggregation-may-2012
 
Java script basics
Java script basicsJava script basics
Java script basics
 
Java Script
Java ScriptJava Script
Java Script
 
Java Script
Java ScriptJava Script
Java Script
 
Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
 
Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016
 
Os Wilhelm
Os WilhelmOs Wilhelm
Os Wilhelm
 

More from Lourens Naudé

ZeroMQ as scriptable sockets
ZeroMQ as scriptable socketsZeroMQ as scriptable sockets
ZeroMQ as scriptable socketsLourens Naudé
 
TX/RX 101: Transfer data efficiently
TX/RX 101: Transfer data efficientlyTX/RX 101: Transfer data efficiently
TX/RX 101: Transfer data efficientlyLourens Naudé
 
In the Loop - Lone Star Ruby Conference
In the Loop - Lone Star Ruby ConferenceIn the Loop - Lone Star Ruby Conference
In the Loop - Lone Star Ruby ConferenceLourens Naudé
 
EuRuKo 2011 - In the Loop
EuRuKo 2011 - In the LoopEuRuKo 2011 - In the Loop
EuRuKo 2011 - In the LoopLourens Naudé
 
Event Driven Architecture
Event Driven ArchitectureEvent Driven Architecture
Event Driven ArchitectureLourens Naudé
 
RailswayCon 2010 - Dynamic Language VMs
RailswayCon 2010 - Dynamic Language VMsRailswayCon 2010 - Dynamic Language VMs
RailswayCon 2010 - Dynamic Language VMsLourens Naudé
 
RailswayCon 2010 - Command Your Domain
RailswayCon 2010 - Command Your DomainRailswayCon 2010 - Command Your Domain
RailswayCon 2010 - Command Your DomainLourens Naudé
 

More from Lourens Naudé (9)

ZeroMQ as scriptable sockets
ZeroMQ as scriptable socketsZeroMQ as scriptable sockets
ZeroMQ as scriptable sockets
 
TX/RX 101: Transfer data efficiently
TX/RX 101: Transfer data efficientlyTX/RX 101: Transfer data efficiently
TX/RX 101: Transfer data efficiently
 
In the Loop - Lone Star Ruby Conference
In the Loop - Lone Star Ruby ConferenceIn the Loop - Lone Star Ruby Conference
In the Loop - Lone Star Ruby Conference
 
EuRuKo 2011 - In the Loop
EuRuKo 2011 - In the LoopEuRuKo 2011 - In the Loop
EuRuKo 2011 - In the Loop
 
Event Driven Architecture
Event Driven ArchitectureEvent Driven Architecture
Event Driven Architecture
 
RailswayCon 2010 - Dynamic Language VMs
RailswayCon 2010 - Dynamic Language VMsRailswayCon 2010 - Dynamic Language VMs
RailswayCon 2010 - Dynamic Language VMs
 
RailswayCon 2010 - Command Your Domain
RailswayCon 2010 - Command Your DomainRailswayCon 2010 - Command Your Domain
RailswayCon 2010 - Command Your Domain
 
Barcamp PT
Barcamp PTBarcamp PT
Barcamp PT
 
Embracing Events
Embracing EventsEmbracing Events
Embracing Events
 

Recently uploaded

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 

Recently uploaded (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 

Railswaycon Inside Matz Ruby

  • 1. Lourens Naudé, Trade2Win Inside Matz Ruby High level Ruby internals crash course.
  • 2. Bio  http://github.com/methodmissing  Ruby contractor  Currently building out a consumer forex platform @ Trade2Win.  creator  scrooge, mysqlplus_adapter, mri_instrumentation  contributor  Rails, mysqlplus, query_memcached, thinking-sphinx, em-spec
  • 3.
  • 4. def users_of( :ruby ) frequently() raise Opinion rescue next_slide.call() end
  • 5. Have you looked at the source ?
  • 6. Mere mortal, with a toolbox  Basic C skills *  Understanding of the UNIX subsystem *  Dtrace *  GDB *  GCC macro expansion *  Add preferred insomnia beverage  * RTFM
  • 7. The Symbol Table  Generic hash implementation – bins && items  Inits with 11 bins, > 5 items per bin spawns more for optimal density  Table.has_many :bins  Bin.has_maby :symbol_table_entries  Strings or numbers as hash keys  Global vars and classes stored in number table  Collisions do happen … expensive
  • 8. Values and identifiers  VALUE and ID is an unsigned long  Special types eg. true, false, nil directly represented by a VALUE … immediates  The infamous nil with ID 4: #define Qnil 4  struct RBasic { unsigned long flags; VALUE klass; };
  • 9. Types  One per builtin type : Array, Symbol etc.  Special hidden types  Mixed in modules  Syntax tree nodes  Variable scope
  • 10. Casting Values  Immediates ( nil ) looked up first for efficiency  ROBJECT(123343434) → T_ARRAY
  • 11. Type Flags  Singleton class ?  Marked for GC ?  Tainted ?  Any finalizers defined ?  Instance variables defined on the object ?  Frozen ?
  • 12. Classes  Instance variables + method table  Super member  Only for Kernel, class->super == NULL  Array->super == Object
  • 13. Objects  Instance var table  Object#method  Searches the method table of it's class  Fallback to superclass on 404  Method cache busted when  MyClass.send( :extend, OtherModule )
  • 14. Method Inclusion  class A include B end  Included class : internal type for module mixins  Pointer to the same ivar && method table
  • 15. Hash  Based on the symbol tables  Iteration, insertion && removal  Iteration level  Track, and act upon, any changes during loops  Mixed in modules
  • 16. String  Min. buffer size is 128 bytes  's' occupies 128 – sizeof('s')  static const char null_str[] = quot;quot;;  New strings point to null_str for efficiency  Locking mechanism  String#gsub  IO.read && IO#sysread buffers
  • 17. Array  Default capacity of 16 elements  [x] occupies sizeof( 16 of x ) – sizeof(x)  Locking mechanism  Array#sort(!)
  • 18. Preallocation  Arrays and strings  Similar structure : length && ptr members  An initial and expandable capacity  Slightly more space allocated to avoid reallocation overheads  Supports sharing of values, where possible
  • 19. Blocks  Snapshots  Optional arguments + a body  Persistent local scope  Linkable  block->prev for iterators
  • 20. Frames  An item on the method call stack  Arguments count and values  Receiver state eg. AClass#method_invoked  Links back to the previous frame  Node state
  • 21. Threads  SIGVTALRM signal reserved  Virtual ring through th->prev && th->next  Evenly timesliced @ 10ms  Threads can block for  A single file descriptor  A select operation  Thread.join && Thread#value
  • 22. Garbage Collection  Process.has_many :heaps  Where objects are stored  Heap.has_many :slots   Heap space maxed  GC runs to free some space  Allocates a new heap * 1.8 bigger
  • 23. GC – Entries  Entries  Wraps core classes, nodes, scope etc.  Reference values  Flags + pointer to the next value  Freelist is special global reference value
  • 24. GC – Allocation and deallocation  Object deallocation  Immediates ignored  Class frees method table, File close it's descriptor etc.  New object allocation  Force GC if no freelist  Reference value assigned from the freelist  Freelist updated to reflect the next free value
  • 25. GC – Mark phase  Object references it's klass, members etc.  Module marks it's methods and ivar table  Ignores immediates  Each object recursively marks others  Sets the marked flag for reference values  Applicable to  Global vars  Variables currently on the stack
  • 26. GC – Sweep phase  Iterates through all objects  Deletes objects not previously marked  Defers sweeping if finalizer registered
  • 28. Follow methodmissing @ github or twitter.Thanks!