Skip to content

Instantly share code, notes, and snippets.

BEFORE:
sam@ubuntu discourse % rm -fr tmp/cache
sam@ubuntu discourse % rm -fr public/assets
sam@ubuntu discourse % time RAILS_ENV=production bin/rake assets:precompile
58.55s user 1.79s system 100% cpu 1:00.02 total
AFTER:
@SamSaffron
SamSaffron / Ruby 2.0
Last active August 29, 2015 13:56
Ruby 2.0 vs 2.1 after running Discourse bench
GC STATS:
count: 1191
heap_used: 1422
heap_length: 1422
heap_increment: 0
heap_live_num: 389339
heap_free_num: 189144
heap_final_num: 0
total_allocated_object: 133699466
total_freed_object: 133310127
@SamSaffron
SamSaffron / gist:8996683
Last active August 29, 2015 13:56
patch perf:
before patch:
---
topic_admin:
50: 24
75: 25
90: 27
99: 46
home_admin:
50: 66
@SamSaffron
SamSaffron / gist:9029928
Last active August 29, 2015 13:56
Raw Bench Results for RubyConf au talk
sam@bench:~/discourse$ chruby 2.0.0-p353
sam@bench:~/discourse$ ruby script/bench.rb -m
---
categories_admin:
50: 109
75: 175
90: 179
99: 207
home_admin:
BEFORE
---
categories_admin:
50: 106
75: 112
90: 143
99: 205
home_admin:
50: 64
class Object
@@acts_like_cache = {}
# A duck-type assistant method. For example, Active Support extends Date
# to define an <tt>acts_like_date?</tt> method, and extends Time to define
# <tt>acts_like_time?</tt>. As a result, we can do <tt>x.acts_like?(:time)</tt> and
# <tt>x.acts_like?(:date)</tt> to do duck-type-safe comparisons, since classes that
# we want to act like Time simply need to define an <tt>acts_like_time?</tt> method.
def acts_like?(duck)
respond_to? (@@acts_like_cache[duck] ||= :"acts_like_#{duck}?")
@retained = []
MAX_STRING_SIZE = 100
def stress(allocate_count, retain_count, chunk_size)
chunk = []
while retain_count > 0 || allocate_count > 0
if retain_count == 0 || (Random.rand < 0.5 && allocate_count > 0)
chunk << " " * (Random.rand * MAX_STRING_SIZE).to_i
allocate_count -= 1
Running in ruby-42105
Duration: 6.152866841
sam 18719 88.0 0.7 226236 197432 pts/1 Sl+ 22:46 0:06 ruby mem.rb
Running in ruby-42110
Duration: 5.485298626
sam 18728 110 1.3 351912 322304 pts/1 Sl+ 22:46 0:05 ruby mem.rb
Running in ruby-42563
Duration: 5.216104843
@SamSaffron
SamSaffron / gist:9162366
Created February 22, 2014 21:03
Full mem test results
@retained = []
@rand = Random.new(1)
MAX_STRING_SIZE = 100
def stress(allocate_count, retain_count, chunk_size)
chunk = []
while retain_count > 0 || allocate_count > 0
if retain_count == 0 || (@rand.rand < 0.5 && allocate_count > 0)
chunk << " " * (@rand.rand * MAX_STRING_SIZE).to_i
sam@ubuntu discourse_docker % ./launcher ssh standalone
Welcome to Discourse Docker
Use: rails, rake or discourse to execute commands in production
root@ubuntu-standalone:~# discourse
Commands:
discourse backup # Backup a discourse forum