+ All Categories
Home > Technology > Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Date post: 12-Apr-2017
Category:
Upload: matthew-gaudet
View: 298 times
Download: 1 times
Share this document with a friend
59
Matthew Gaudet, February 4 th , 2017 Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Transcript
Page 1: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Matthew Gaudet, February 4th, 2017

Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Page 2: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

What’s Ruby+OMR again?

Page 3: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

An Open Source Toolkit for Language

Runtime Technologies.

Page 4: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Garbage

Collector

JIT Compiler

Monitoring

Porting Library

…More!

Page 5: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Goal: Compatibility!

Integrate vs. Replace

Page 6: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

+

Page 7: Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Page 8: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

8

Page 9: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Status Update: 13 Months later

Page 10: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

10

Page 11: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

11

No JIT….

Page 12: Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Page 13: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

13

Page 14: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

14

Page 15: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Today:

Branch ruby_2_4_omr is current default.

– Based of ruby_2_4 tag

JIT Compiler Hooked up and running Travis tests for OS/X and Linux

– Known issues in make test-all

– Passing make test with count=0

Populated and tagged Issue Tracker

Performance: Less specialization to micro benchmarks, means lower

seeming performance.

– Better software engineering

https://github.com/rubyomr-preview/ruby/issues/

Page 16: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

JIT integration

Functional Correctness has been primary objective

– Aiming for pass of test suite at all optimization levels.

–No restrictions on native code used by extension modules

Have added some optimizations, but haven’t done much in the way of

tuning.

Simple compilation control

Page 17: Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Page 18: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Our Goal:

YES

Be Part of Delivering 3x3

Page 19: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Why?

We think Ruby could really benefit from having a JIT

compiler.

Lots of pre-built JIT compiler technology in OMR, with

potential for exploitation in Ruby.

What’s in it for us? Validation of the OMR approach

–Community improvement: Having multiple consumers

helps us make it better for everyone!

Page 20: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

https://twitter.com/ChrisGSeaton/status/811303853488488448

Page 21: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Competition and Collaboration

Having multiple JITs for CRuby could be a really good thing!

Share the load of creating interface and infrastructure that all

JITs for CRuby can rely on.

Competition helps push things forward

Collaboration helps solve hard problems!

21

Page 22: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

22 https://twitter.com/ChrisGSeaton/status/811332662350794752

Page 23: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

23

Effort!

Re

su

lts!

Page 24: Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Page 25: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Community Challenges!

Page 26: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

https://twitter.com/tenderlove/status/765288

21993188147226

Page 27: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Make Tradeoffs that are Right for the Ruby Community

JIT Compilation:

Trade startup speed for peak speed.

Trade footprint for speed.

Page 28: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

What do we prioritize?

Time to First Request?

Time to Peak

Performance?

Peak Performance?

100

64 69

3625 30 25 26 25 26 25

1 2 3 4 5 6 7 8 9 10 11

Time per Iteration (s)

Prioritization will be driven by benchmarks from the community.

Page 29: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

1. Some CPU intensive applications: OptCarrot2. Some memory intensive application: 3. A startup benchmark: time ruby -e “def f; ‘100’; end; puts f”?

4. Some web application framework benchmark(s)?

http://rubykaigi.org/2016/presentations/MattStudies.html

Benchmarks to aim for?

http://engineering.appfolio.com/appfolio-engineering/2016/12/8/benchmarking-rails

Page 30: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Information Challenges

Page 31: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

MRI

Garbage Collector

Ruby IL Generator Optimizer

Code Generator

Runtime Code Cache

YARV Interpreter

Page 32: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

JIT VM Symbiosis

VMJIT

Performance

Information

JIT ↔ VM Interface

Page 33: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Infrequent Event Notification

Operations such as

Basic Operation Redefinition

Constant Modification

Class Hierarchy changes.

Unlocks:

–More aggressive specialization, class hierarchy

optimization. Don’t create code for things that haven’t

happened yet!

Page 34: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Stack Peeking Notification

A hook that fires when some piece of code wants to look at a

stack frame – Give the JIT compiler a chance to materialize

what it should have looked like.

Unlocks

–On Stack Replacement: Don’t Execute Code for Things

that might happen!

Page 35: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Basic Block Frequencies

How many times has this basic block been executed?

Unlocks:

Better Optimization: Don’t spend time compiling

on things that won’t get executed!

?

Page 36: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Type Profiling

What types have we seen for this value?

Unlocks:

Speculation and Specialization: Generate code for

the cases we think will happen!

Page 37: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Horizon Challenges

Page 38: Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Page 39: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Much of MRI’s core functionality is written in C!

A problem for the optimization horizon!

Page 40: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Optimization Horizon Solutions?

Rewrite all of core in Ruby.

‘Lift the Core’

40

Page 41: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Optimization Horizon Solutions?

Incremental Ruby-fication:

More promising… and easy to get started on in Ruby!

Convert prelude.rb to a ‘prelude’ directory, where Ruby implementations

live.

– Startup concerns (parse overheads) – can be mitigated with YARV

bytecode serialization.

– Longer term: JIT AOT Compilation maybe!

41

Page 42: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Optimization Challenges

Page 43: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

An admission:

Page 44: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Testing Challenges

Page 45: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

JIT Testing is Hard!

Normal Tests

Finish quickly

Coverage with minimal repetition.

Local reasoning / isolation

No special command lines

Compiler Stress Tests

Need to run code multiple times! – Allow the JIT to kick in, profile data

to be collected, and consumed

Potentially require global

reasoning.

Run in multiple VM instances

under different options.

Writing test cases that can effectively stress the JIT compiler is an art

Page 46: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

JIT Testing is Hard!

Other problems:

Isolating test cases from each

other

Time accuracy trade off

Coverage

All these problems of JIT

testing will also be equally

true when running a

gem’s test suite with a

JIT...

Page 47: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

My Personal Ruby Hero

Patched ruby/spec to

allow it to work with

repetition

Great win for JIT testing!

Page 48: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Engineering Challenges

Page 49: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Keeping up with the firehose?

How do we keep up to date with the Ruby core?

Some is good software engineering… callback generation was

done precisely to address this concern. But more still needed!

Page 50: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

The JIT Needs some cleanup

Callback Generator Ruby code isn’t very good!

–https://github.com/rubyomr-preview/ruby/issues/74

Great task for someone good at writing Ruby!

The makefiles need love

– https://github.com/rubyomr-preview/ruby/issues/8

Page 51: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

OMR Challenges

Page 52: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

OMR is evolving!

We’ve only been open source for 4.5 months!

Still working on improving our interfaces, our

integration story.

Need to build out a community! This is where you

can help!

Page 53: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Mentorship

I’m committed to helping anyone who

wants to contribute to Ruby+OMR

get up and running.

I’ll write documentation for things that are

unclear

I’ll answer email!I’ll help guide

implementationI’ll be on slack!

I’ll schedule a video chat with you!

Page 54: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Ruby+OMR needs community

interest to survive!

Page 55: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

My To-Do List!

1. Make My Mentorship Commitment Clear!

2. I need to start collecting feedback from ruby-coreon what we would need to do to get community

members interested.

3. I need to start demonstrating the kinds of VM

changes a JIT will need.

Page 56: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

The Audience To-Do List!

1. Give Ruby+OMR a try

2. Open Issues!

3. Ask about helping! Little things are equally

appreciated!

Page 57: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

My thoughts on hitting 3x3:

57

The Work Ahead!

JIT Work VM Work

The VM Work I hope can be shared among competition!

Page 58: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Thank you so much!

Page 59: Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Acknowledgements

https://en.wikipedia.org/wiki/Foundation_%28engineering%29#/media/File:Concrete_cellar_

10007.JPG

http://emojipedia.org/mozilla/firefox-os-2.5/confused-face/


Recommended