7. one iteration takes ~ 100ms
Garbage collection
Need one Gb?
Expect 128 GC calls!
You lose 128*0,1 = 12,8 sec
Allocated memory never returns to the system!
runs on every 8Mb of allocated memory
14. What can I do to improve performance?
Use C extensions or gems
Use plain SQL instead of frameworks
Use CPU and memory profiling
Use Rubinius or JRuby
33. What should I remeber before profiling?
Turn GC off (GC.disable)
class Foo
def do_smth
return "x" * 1024 # take one Kb of memory
end
end
smth = "x" * 7999999 # alloc almost 8Mb
Foo.new.do_smth # here GC will be called
do_smth is so slow!!!