Speed Science

Speed Science

Run your app faster, with less RAM and a quicker boot time today. How? With science! In this talk we'll focus on the process of turning performance problems into reproducible bugs we can understand and squash. We'll look at real world use cases where small changes resulted in huge real world performance gains. You'll walk away with concrete and actionable advice to improve the speed of your app, and with the tools to equip your app for a lifetime of speed. Live life in the fast lane, with science!

Db953d125f5cc49756edb6149f1b813e?s=128

Richard Schneeman

April 21, 2015
Tweet

Transcript

  1. 4.
  2. 9.
  3. 11.
  4. 13.
  5. 14.
  6. 18.
  7. 22.
  8. 24.
  9. 25.

    BTW

  10. 28.
  11. 31.
  12. 32.
  13. 35.
  14. 38.
  15. 43.
  16. 50.
  17. 58.
  18. 60.
  19. 64.
  20. 65.

    ER

  21. 66.
  22. 67.
  23. 77.

    GO

  24. 78.
  25. 84.
  26. 89.
  27. 90.
  28. 91.
  29. 93.
  30. 102.

    RAM

  31. 109.
  32. 110.
  33. 111.
  34. 113.

    Memory “1” “2” “3”“4” “5” “6” “7” RETAINED = []

    1.upto(100_000_000).each do |i| RETAINED << “#{i}” end
  35. 118.
  36. 125.

    def make_objects array = [] 1.upto(100_000_000).each do |i| array <<

    "#{i}" end return nil end make_objects GC.start(full_mark: true, immediate_sweep: true)
  37. 126.

    def make_objects array = [] 1.upto(100_000_000).each do |i| array <<

    "#{i}" end return nil end make_objects GC.start(full_mark: true, immediate_sweep: true)
  38. 127.

    def make_objects array = [] 1.upto(100_000_000).each do |i| array <<

    "#{i}" end return nil end make_objects GC.start(full_mark: true, immediate_sweep: true)
  39. 128.
  40. 129.
  41. 130.

    WAT

  42. 131.

    GC.start(full_mark: true, immediate_sweep: true) GC.disable # Code goes here before

    = GC.stat[:total_freed_objects] GC.enable GC.start(full_mark: true, immediate_sweep: true) after = GC.stat[:total_freed_objects] # => “Objects cleared by GC: 100_010_687”
  43. 134.
  44. 137.
  45. 139.
  46. 154.
  47. 166.
  48. 168.
  49. 169.
  50. 182.

    allocated memory by gem ----------------------------------- rack-1.5.2 x 6491 actionpack-4.1.2 x

    4888 hashie-3.3.1 x 4735 <============== activesupport-4.1.2 x 3292 omniauth-1.2.2 x 1387 actionview-4.1.2 x 1107 ruby-2.1.2/lib x 1097 railties-4.1.2 x 925 activerecord-4.1.2 x 440 warden-1.2.3 x 200 codetriage-test-app/app x 40 other x 40
  51. 200.
  52. 201.

    active_record/connection_adapters/postgresql_adapter: 2.2734375 active_record/connection_adapters/postgresql_adapter: 2.2734 mb active_record/connection_adapters/postgresql/oid: 0.8555 mb will_paginate/active_record: 1.4921875

    will_paginate/active_record: 1.4922 mb active_support/all: 1.01171875 active_support/all: 1.0117 mb active_support/core_ext: 0.9727 mb rack/test: 0.875 rack/test: 0.875 mb /Users/richardschneeman/Documents/projects/codetriage/app/models/user: 0.734375 /Users/richardschneeman/Documents/projects/codetriage/app/models/user: 0.7344 mb /Users/richardschneeman/Documents/projects/codetriage/app/models/repo: 0.50390625 /Users/richardschneeman/Documents/projects/codetriage/app/models/repo: 0.5039 mb new_relic/control/frameworks/rails4: 0.42578125 new_relic/control/frameworks/rails4: 0.4258 mb new_relic/control/frameworks/rails3: 0.3867 mb benchmark/ips: 0.4140625 benchmark/ips: 0.4141 mb will_paginate/view_helpers/action_view: 0.32421875 will_paginate/view_helpers/action_view: 0.3242 mb /Users/richardschneeman/Documents/projects/codetriage/app/models/issue: 0.31640625 /Users/richardschneeman/Documents/projects/codetriage/app/models/issue: 0.3164 mb /Users/richardschneeman/Documents/projects/codetriage/app/models/repo_subscription: 0.2734375 /Users/richardschneeman/.gem/ruby/2.2.1/gems/devise-3.4.1/app/mailers/devise/mailer: 0.265625 sprockets/base: 0.23046875 active_support/cache/dalli_store: 0.22265625 /Users/richardschneeman/Documents/projects/codetriage/app/models/issue_assignment: 0.18359375 /Users/richardschneeman/Documents/projects/codetriage/app/controllers/users/after_signup_controller: 0.18359375 /Users/richardschneeman/.gem/ruby/2.2.1/gems/wicked-1.0.0/app/controllers/wicked/wizard_controller: 0.1796875 /Users/richardschneeman/Documents/projects/codetriage/app/mailers/user_mailer: 0.1796875 /Users/richardschneeman/.gem/ruby/2.2.1/gems/devise-3.4.1/app/controllers/devise/ confirmations_controller: 0.17578125 /Users/richardschneeman/Documents/projects/codetriage/app/controllers/repos_controller: 0.17578125
  53. 202.

    active_record/connection_adapters/postgresql_adapter: 2.2734375 active_record/connection_adapters/postgresql_adapter: 2.2734 mb active_record/connection_adapters/postgresql/oid: 0.8555 mb will_paginate/active_record: 1.4921875

    will_paginate/active_record: 1.4922 mb active_support/all: 1.01171875 active_support/all: 1.0117 mb active_support/core_ext: 0.9727 mb rack/test: 0.875 rack/test: 0.875 mb /Users/richardschneeman/Documents/projects/codetriage/app/models/user: 0.734375 /Users/richardschneeman/Documents/projects/codetriage/app/models/user: 0.7344 mb /Users/richardschneeman/Documents/projects/codetriage/app/models/repo: 0.50390625 /Users/richardschneeman/Documents/projects/codetriage/app/models/repo: 0.5039 mb new_relic/control/frameworks/rails4: 0.42578125 new_relic/control/frameworks/rails4: 0.4258 mb new_relic/control/frameworks/rails3: 0.3867 mb benchmark/ips: 0.4140625 benchmark/ips: 0.4141 mb will_paginate/view_helpers/action_view: 0.32421875 will_paginate/view_helpers/action_view: 0.3242 mb /Users/richardschneeman/Documents/projects/codetriage/app/models/issue: 0.31640625 /Users/richardschneeman/Documents/projects/codetriage/app/models/issue: 0.3164 mb /Users/richardschneeman/Documents/projects/codetriage/app/models/repo_subscription: 0.2734375 /Users/richardschneeman/.gem/ruby/2.2.1/gems/devise-3.4.1/app/mailers/devise/mailer: 0.265625 sprockets/base: 0.23046875 active_support/cache/dalli_store: 0.22265625 /Users/richardschneeman/Documents/projects/codetriage/app/models/issue_assignment: 0.18359375 /Users/richardschneeman/Documents/projects/codetriage/app/controllers/users/after_signup_controller: 0.18359375 /Users/richardschneeman/.gem/ruby/2.2.1/gems/wicked-1.0.0/app/controllers/wicked/wizard_controller: 0.1796875 /Users/richardschneeman/Documents/projects/codetriage/app/mailers/user_mailer: 0.1796875 /Users/richardschneeman/.gem/ruby/2.2.1/gems/devise-3.4.1/app/controllers/devise/ confirmations_controller: 0.17578125 /Users/richardschneeman/Documents/projects/codetriage/app/controllers/repos_controller: 0.17578125
  54. 207.
  55. 214.
  56. 216.
  57. 217.
  58. 218.
  59. 219.
  60. 220.
  61. 221.
  62. 222.
  63. 223.
  64. 224.
  65. 225.
  66. 226.
  67. 228.

    application: 60.8242 mb mail: 39.2734 mb mail/parsers: 19.2461 mb mail/parsers/ragel:

    18.7031 mb mail/parsers/ragel/ruby: 18.6797 mb mail/parsers/ragel/ruby/machines/address_lists_machine: 7.2734 mb mail/parsers/ragel/ruby/machines/received_machine: 4.7578 mb mail/parsers/ragel/ruby/machines/envelope_from_machine: 2.2305 mb mail/parsers/ragel/ruby/machines/message_ids_machine: 1.5625 mb mail/parsers/ragel/ruby/machines/date_time_machine: 0.5977 mb mail/parsers/ragel/ruby/machines/content_disposition_machine: 0.4961 mb mail/parsers/ragel/ruby/machines/content_type_machine: 0.4648 mb mail/parsers/ragel/ruby/machines/content_location_machine: 0.3359 mb mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine: 0.3281 mb mail/parsers/ragel/ruby/machines/phrase_lists_machine: 0.3086 mb mime/types: 18.4922 mb mail/field: 0.3125 mb
  68. 229.

    application: 60.8242 mb mail: 39.2734 mb mail/parsers: 19.2461 mb mail/parsers/ragel:

    18.7031 mb mail/parsers/ragel/ruby: 18.6797 mb mail/parsers/ragel/ruby/machines/address_lists_machine: 7.2734 mb mail/parsers/ragel/ruby/machines/received_machine: 4.7578 mb mail/parsers/ragel/ruby/machines/envelope_from_machine: 2.2305 mb mail/parsers/ragel/ruby/machines/message_ids_machine: 1.5625 mb mail/parsers/ragel/ruby/machines/date_time_machine: 0.5977 mb mail/parsers/ragel/ruby/machines/content_disposition_machine: 0.4961 mb mail/parsers/ragel/ruby/machines/content_type_machine: 0.4648 mb mail/parsers/ragel/ruby/machines/content_location_machine: 0.3359 mb mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine: 0.3281 mb mail/parsers/ragel/ruby/machines/phrase_lists_machine: 0.3086 mb mime/types: 18.4922 mb mail/field: 0.3125 mb
  69. 234.
  70. 235.
  71. 236.

    To

  72. 237.
  73. 243.
  74. 250.
  75. 262.
  76. 276.