Skip to content

Instantly share code, notes, and snippets.

@SamSaffron
Last active August 29, 2015 13:56
Show Gist options
  • Save SamSaffron/9152762 to your computer and use it in GitHub Desktop.
Save SamSaffron/9152762 to your computer and use it in GitHub Desktop.
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
sam 19509 104 1.3 351260 322404 pts/1 Sl+ 22:54 0:05 ruby mem.rb
Running in ruby-42568
Duration: 5.388427669
sam 19518 108 1.0 288260 258576 pts/1 Sl+ 22:54 0:05 ruby mem.rb
Running in ruby-42866
Duration: 5.67313438
sam 20248 94.6 1.0 290052 258860 pts/1 Sl+ 22:59 0:05 ruby mem.rb
Running in ruby-42871
Duration: 6.087088135
sam 20257 101 0.8 234980 201416 pts/1 Sl+ 23:00 0:06 ruby mem.rb
Running in ruby-43069
Duration: 5.81778172
sam 20584 97.0 0.8 229084 198420 pts/1 Sl+ 23:03 0:05 ruby mem.rb
Running in ruby-43074
Duration: 5.724598436
sam 20594 95.6 1.1 325176 293444 pts/1 Sl+ 23:03 0:05 ruby mem.rb
Running in ruby-43333
Duration: 5.417208553
sam 21044 108 1.2 341352 308652 pts/1 Sl+ 23:08 0:05 ruby mem.rb
Running in ruby-43338
Duration: 5.634901383
sam 21053 94.1 1.0 282668 251036 pts/1 Sl+ 23:08 0:05 ruby mem.rb
Running in ruby-43534
Duration: 6.259690269
sam 21382 104 0.9 262248 232516 pts/1 Sl+ 23:12 0:06 ruby mem.rb
Running in ruby-43539
Duration: 5.740280076
sam 21391 95.8 1.1 318660 289292 pts/1 Sl+ 23:12 0:05 ruby mem.rb
@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
if chunk.length > chunk_size
chunk = []
end
else
@retained << " " * (Random.rand * MAX_STRING_SIZE).to_i
retain_count -= 1
end
end
end
start = Time.now
stress(10_000_000, 600_000, 200_000)
puts "Duration: #{(Time.now - start).to_f}"
puts `ps aux | grep #{Process.pid} | grep -v grep`
EG:
RSS in 42105 is 226mb
RSS in 42110 is 322mb
its the output of ps aux, so vsz first, rss second
@SamSaffron
Copy link
Author

This was a collection of interesting RSS consumed due to script in Ruby builds in the last year ... ran it on every 5 builds.

The script attempts to be a rough simulation of a rails web app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment