Slide 1

Slide 1 text

Solve your problem, speed up your life, and paint it black with Ruby! Akira Matsuda

Slide 2

Slide 2 text

Please allow me to introduce myself

Slide 3

Slide 3 text

I'm a man of Ruby and Rails

Slide 4

Slide 4 text

Rails Ruby

Slide 5

Slide 5 text

Pleased to meet you

Slide 6

Slide 6 text

Hope you guess my name

Slide 7

Slide 7 text

My name •GitHub: amatsuda •Twitter: @a_matsuda

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

We meetup on every Ruby Tuesday

Slide 10

Slide 10 text

Members and ...

Slide 11

Slide 11 text

From all over Asakusa

Slide 12

Slide 12 text

From all over Japan

Slide 13

Slide 13 text

From all over the World!

Slide 14

Slide 14 text

I'm a Rubyist.

Slide 15

Slide 15 text

begin

Slide 16

Slide 16 text

Ruby is different today. I hear every programmer say •Ruby is a "web language" •Ruby is a "slow language"

Slide 17

Slide 17 text

Ruby.is_a? web language

Slide 18

Slide 18 text

Ruby.is_a? web language •Obviously it is!

Slide 19

Slide 19 text

I use Ruby because...

Slide 20

Slide 20 text

I use Ruby because... •I'm a web programmer.

Slide 21

Slide 21 text

I use Ruby because... •I'm a web programmer. •Every web programmer uses Rails.

Slide 22

Slide 22 text

I use Ruby because... •I'm a web programmer. •Every web programmer uses Rails. •Ruby is the language "under Rails".

Slide 23

Slide 23 text

Why Ruby? •Rails is my business... and business is good! •I'm not playing on Ruby, I'm just working on Rails.

Slide 24

Slide 24 text

I hear every programmer say •Ruby is a "web language" •Ruby is a "slow language"

Slide 25

Slide 25 text

Ruby.is_a? slow language

Slide 26

Slide 26 text

I heard people say Ruby is slow, so what shall I do?

Slide 27

Slide 27 text

New trolls! •Submit a CFP titled "7 reasons why Ruby is slow" for a Ruby conference. Immediately. •Be quick, or be dead you'll miss a chance to get up on stage.

Slide 28

Slide 28 text

7 reasons? •They say GC is slow. •They say Ruby is slow because of the "GIL" thing.

Slide 29

Slide 29 text

"GIL" (or GVL) • What exactly is it? • Don't ask me. I don't know. Ask @_ko1 or @kosaki55tea • No, actually you need not to know about it. • I hear every programmer say JRuby or Rubinius are better and faster than MRI because they are GIL free. So let's just throw MRI away.

Slide 30

Slide 30 text

GIL free! •Thank Matz Almighty, we are free at last! •Roll over @yotii23's husband, tell Patch Monster the news.

Slide 31

Slide 31 text

How is it free? •Let's take a look.

Slide 32

Slide 32 text

Concurrency is such a lonely word. Every Thread is so untrue. array = [] 5.times.map do Thread.new do 1000.times do array << nil end end end.each(&:join) puts array.size http://www.jstorimer.com/blogs/workingwithcode/8085491-nobody-understands-the-gil

Slide 33

Slide 33 text

Concurrency is hardly ever heard. And mostly what we need from Ruby. •% ruby -v thread_tes.rb ruby 2.1.0dev (2013-10-14 trunk 43282) [x86_64-darwin12.5.0] 5000 •% ruby -v thread_tes.rb rubinius 2.1.1 (2.1.0 be67ed17 2013-10-18 JI) [x86_64-darwin12.5.0] 3504

Slide 34

Slide 34 text

OMG

Slide 35

Slide 35 text

But ... but I still feel like Ruby is kind of slow for me, so what can I do?

Slide 36

Slide 36 text

No trolls! •Submit a CFP titled "7 reasons why Ruby is slow" for a Ruby conference. Immediately.

Slide 37

Slide 37 text

:trollface:

Slide 38

Slide 38 text

Don't troll. Code. • Unless you're a VM programmer, shut your mouth. • That's @_Ko1's business. • That's why Heroku pays @_ko1's salary. • Instead, nd a problem that YOU can deal with. • And don't let it be. Don't whisper words of wisdom. Solve it.

Slide 39

Slide 39 text

I know a person who actually have been doing this •He thought Rails is slow because assets are slow. •=> The asset pipeline •He thought Rails is slow because we are reloading assets for every request. •=> Turbolinks

Slide 40

Slide 40 text

He's the speed king

Slide 41

Slide 41 text

Your Rails app is slow because... •Kernel#require is slow •RubyGems & Bundler is slow •ActiveRecord is slow •RSpec is slow •Rack is slow

Slide 42

Slide 42 text

Kernel#require •@_ko1 told me that require_relative would be way faster than require •So we tried

Slide 43

Slide 43 text

https://github.com/amatsuda/ rails/tree/require_relative •Rewriting 544 `require` calls to `require_relative`

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

'Cause I try and I try and I try and I try • Before: % time rails r 1 4.07s user 1.32s system 95% cpu 5.650 total % time rails r 1 3.91s user 1.15s system 99% cpu 5.087 total % time rails r 1 3.91s user 1.17s system 99% cpu 5.107 total • After: % time rails r 1 4.20s user 1.24s system 99% cpu 5.467 total % time rails r 1 3.98s user 1.17s system 99% cpu 5.167 total % time rails r 1 3.99s user 1.15s system 99% cpu 5.169 total

Slide 46

Slide 46 text

I can't get no! I can't get no! •NO performance improvement!

Slide 47

Slide 47 text

Hail, hail to Bundler •It turned out that RubyGems rewrites Kernel#require and makes it slow, but Bundler re- rewrites it and makes it fast nally.

Slide 48

Slide 48 text

The problems I recently found

Slide 49

Slide 49 text

database_cleaner is slow

Slide 50

Slide 50 text

10% of `time rake spec` was spent for DB cleaning •time rake spec: 14m01s •time spent on cleaning DB: 77m35s

Slide 51

Slide 51 text

So I rewrote database_cleaner •Come cleaning faster! •Just call `delete` if I hear `insert` •FIX ME!

Slide 52

Slide 52 text

amatsuda/ database_rewinder

Slide 53

Slide 53 text

Speedy's coming •time rake spec: 13m15s •time spent on cleaning DB: 0m8s

Slide 54

Slide 54 text

Loading a huge HTML is slow

Slide 55

Slide 55 text

lazy-load partials •Separate a huge webpage into several partials. Then load the partials via separate requests. •Rails views already have "partials". •What if partials are lazy-load- able?

Slide 56

Slide 56 text

amatsuda/ ljax_rails

Slide 57

Slide 57 text

ljax_rails <%= render 'users' %> => •<%= render 'users', remote: true %>

Slide 58

Slide 58 text

bundler is slow •$LOAD_PATH

Slide 59

Slide 59 text

In our mid-sized app's case % rails r 'puts $:' | grep gems | wc -l 200

Slide 60

Slide 60 text

Can't they be squashed into one lib/ directory? •Because each gem are basically namespaced. •The only thing that looks good on me, at runtime, is lib/ directory in most cases.

Slide 61

Slide 61 text

Current directory structure ᵓᴷᴷ gem1 ᴹ ᵋᴷᴷ lib >> LOAD_PATH ᴹ ᵓᴷᴷ gem1 ᴹ ᴹ ᵓᴷᴷ bar.rb ᴹ ᴹ ᵋᴷᴷ foo.rb ᴹ ᵋᴷᴷ gem1.rb ᵋᴷᴷ gem2 ᵋᴷᴷ lib >> $LOAD_PATH ᵋᴷᴷ gem2 ᵓᴷᴷ fuga.rb ᵋᴷᴷ hoge.rb

Slide 62

Slide 62 text

Squash all gems into one directory ᵋᴷᴷ all_bundled_gems_in_one ᵋᴷᴷ lib >> LOAD_PATH ᵓᴷᴷ gem1 ᴹ ᵓᴷᴷ bar.rb ᴹ ᵋᴷᴷ foo.rb ᵓᴷᴷ gem1.rb ᵋᴷᴷ gem2 ᵓᴷᴷ fuga.rb ᵋᴷᴷ hoge.rb

Slide 63

Slide 63 text

(bundle_squash) •(It should be possible) •(But not yet on the Web...)

Slide 64

Slide 64 text

Problems I'm willing to challenge •Make Haml faster •Or create a faster fork of Haml •Make ActiveRecord faster •Or create a faster subset of AR

Slide 65

Slide 65 text

Haml

Slide 66

Slide 66 text

Ruby.is_a? web language •(reprise)

Slide 67

Slide 67 text

Ruby.is_a? web language and !Ruby.is_a? web_only language •Ruby off Rails!

Slide 68

Slide 68 text

One thing I hate on my computer

Slide 69

Slide 69 text

One thing I hate on my computer

Slide 70

Slide 70 text

Who here are happy with the Finder.app?

Slide 71

Slide 71 text

Finder.app •Mr. Finder.app, what went down in your head •Your UI to me seems so tragic, with the thrill of it all

Slide 72

Slide 72 text

At Railsษڧձ@౦ژ last month •We talked about how Finder.app sucks •We agreed that we need a better " ler" •And I started creating it last month.

Slide 73

Slide 73 text

Why Finder.app sucks

Slide 74

Slide 74 text

Why Finder.app sucks •Productivity •Design

Slide 75

Slide 75 text

Productivity • It's so hard to do simple things such as `mkdir`, `rm`, or `cd` to a hidden directory. • How can I `touch`? How can I `ln -s`? How can I `chmod`? • Telling me more and more about some useless features. Supposed to : re: my productivity.

Slide 76

Slide 76 text

Design •It's white!

Slide 77

Slide 77 text

Paint it black! •I see a white window and I want it painted black.

Slide 78

Slide 78 text

Paint it black!

Slide 79

Slide 79 text

Paint it black! •No colors anymore I want them to turn black.

Slide 80

Slide 80 text

Paint it black!

Slide 81

Slide 81 text

So, I made my own nder •And saw that it was good.

Slide 82

Slide 82 text

How can Finder.app be better? •Needs to be more productive. •Needs to be painted black.

Slide 83

Slide 83 text

Clone FD

Slide 84

Slide 84 text

FD •It's only a DOS application but I like it.

Slide 85

Slide 85 text

About FD •http://news.mynavi.jp/articles/ 2012/11/20/FD/ •A legendary " ler" for MS-DOS •Firstly released in 1989

Slide 86

Slide 86 text

Do ya think I'm sexy? •This tool is not very glamorous but still very sexy.

Slide 87

Slide 87 text

Get back to where you once belonged

Slide 88

Slide 88 text

What a drag it is getting old •Am I sticking to an old tool that I'm used to because I'm too old to learn new tools? •No. I'm creating this not just for nostalgy but for productivity.

Slide 89

Slide 89 text

Technologies •Xnix •Terminal •Ruby •Curses

Slide 90

Slide 90 text

amatsuda/rfd % gem i rfd

Slide 91

Slide 91 text

Concept, design •FD + Vim •Simple MVC •M: les & directories •V: Curses •C: logic •Customizable, plugin-able architecture

Slide 92

Slide 92 text

Implementation •Basically commands are one- char •Each command is de ned as a method in commands.rb •Pressing a key simply runs that method (send)

Slide 93

Slide 93 text

rfd commands •Moving the cursor •Manipulating les •Viewing, Editing •Manipulating archives

Slide 94

Slide 94 text

TODO •tree view •command customization •color customization •undo •watchr

Slide 95

Slide 95 text

Summary (1) •I use Ruby to solve "my" problem •OSS != volunteering. No need to "contribute" to someone else. Start with "your" problem. It's a very good place to start.

Slide 96

Slide 96 text

Summary (2) •Ruby is slow, and I'm trying to make it faster. •You can do it even if you're not a VM hacker or a GC hacker. •There're many unoptimized parts left in the whole Rails app stack.

Slide 97

Slide 97 text

Summary (3) •I'm painting it black with Ruby. •It works ne, and I'm happy with that.

Slide 98

Slide 98 text

Conclusion •Play with Ruby for fun rather than just work with Ruby for money! •Let's spend the night with Ruby!

Slide 99

Slide 99 text

No content