Slide 1

Slide 1 text

Tunando o seu código Ruby

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

André Luís @ndrluis

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

VAMOS FALAR DE COISA BOA?

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

RUBY É LENTO?

Slide 12

Slide 12 text

RAILS É LENTO?

Slide 13

Slide 13 text

TUNAR GC É NECESSARIO?

Slide 14

Slide 14 text

http://helabs.com/blog/2014/12/19/ruby-gc-tuning-parameters/ http://www.akitaonrails.com/2015/03/27/small-bites-novidades-no- garbage-collector-do-ruby-2-2-1#.VYTSx2DrdBU http://www.infoq.com/br/presentations/entendendo-garbage- collector-ruby

Slide 15

Slide 15 text

APRENDA A MENSURAR

Slide 16

Slide 16 text

https://github.com/schneems/derailed_benchmarks Richard Schneeman

Slide 17

Slide 17 text

$ derailed bundle:mem TOP: 87.5938 mb carrierwave: 35.9023 mb carrierwave/storage: 27.2773 mb fog: 27.125 mb fog/joyent: 5.2266 mb fog/joyent/compute: 5.1641 mb net/ssh: 4.9297 mb net/ssh/transport/session: 2.5977 mb net/ssh/transport/algorithms: 1.7188 mb net/ssh/transport/kex: 0.4375 mb net/ssh/transport/hmac: 0.375 mb net/ssh/transport/packet_stream: 0.5078 mb net/ssh/authentication/session: 1.0508 mb net/ssh/authentication/key_manager: 0.5039 mb net/ssh/connection/session: 0.9531 mb net/ssh/connection/channel: 0.3203 mb

Slide 18

Slide 18 text

refile/rails: 0.9688 mb refile: 0.9688 mb rest_client: 0.6367 mb /Users/…/lib/restclient: 0.6367 mb /Users/…/lib/restclient/abstract_response: 0.4844 mb http-cookie: 0.4844 mb http/cookie: 0.4805 mb domain_name: 0.3984 mb domain_name/etld_data: 0.3789 mb

Slide 19

Slide 19 text

$ derailed bundle:objects allocated objects by gem ----------------------------------- 281 refile-0.5.5 2499 carrierwave-0.10.0

Slide 20

Slide 20 text

$ derailed bundle:mem TOP: 89.2617 mb activeadmin: 24.1797 mb active_admin: 24.1797 mb ransack: 6.9805 mb ransack/adapters/active_record: 3.0039 mb action_view/view_paths: 0.6992 mb action_view/base: 0.6328 mb ransack/search: 0.4063 mb action_dispatch/http/request: 0.3828 mb active_admin/batch_actions: 4.0039 mb

Slide 21

Slide 21 text

Refile > Carrierwave RailsAdmin > ActiveAdmin

Slide 22

Slide 22 text

NÃO NECESSARIAMENTE

Slide 23

Slide 23 text

refile/rails: 2.3555 mb refile: 2.2539 mb rest_client: 1.7109 mb

Slide 24

Slide 24 text

LOGO…..

Slide 25

Slide 25 text

SABER MENSURAR É IMPORTANTE

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Benchmark

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

benchmark-ips https://github.com/evanphx/benchmark-ips

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

slow 47524.3 (± 7.6%) i/s fast 56823.2 (± 7.2%) i/s 20% mais rapido

Slide 33

Slide 33 text

CUIDADO COM OPTIMIZAÇÃO PREMATURA!

Slide 34

Slide 34 text

CRIE MENOS OBJETOS!

Slide 35

Slide 35 text

Obrigado!