Memory profiling

I’m doing a bit of memory testing in my 4.1 tree, and I haven’t found
anything all that exciting yet. I’m using a objectspace profiler by
Ryan D., lightly modified to produce a bit more info. Two things
seem obvious:

  1. Cached hits don’t leak anything. The total number of objects
    per type in the system doesn’t change at all .

  2. Uncached hits leak 1-3 strings per page.

I haven’t tested admin yet.

Here’s the profiler. Start it from environment.rb and it’ll log to a
file.

class MemoryProfiler
def self.start(delay=10)
Thread.new do
prev = Hash.new(0)
curr = Hash.new(0)
delta = Hash.new(0)

  file = File.open('log/memory_profiler.log','w')

  loop do
    begin
      GC.start
      curr.clear
      ObjectSpace.each_object do |o|
        curr[o.class] += 1 #Marshal.dump(o).size rescue 1
      end

      delta.clear
      (curr.keys + delta.keys).uniq.each do |k,v|
        delta[k] = curr[k]-prev[k]
      end

      file.puts "Top 20"
      delta.sort_by { |k,v| -v.abs }[0..19].sort_by { |k,v|

-v}.each do |k,v|
file.printf “%+5d: %s (%d)\n”, v, k.name, curr[k] unless v
== 0
end
file.flush

      delta.clear
      prev.clear
      prev.update curr
    rescue Exception => err
      STDERR.puts "** memory_profiler error: #{err}"
    end
    sleep delay
  end
end

end
end

Anyone using Mongrel Rails with Typo?

We ended up having to turn off caching to get it to work correctly.
Anyone
else have some insight?

-Linda

It’s worked fine for me in testing. Which version of Typo, and what
do you mean by “work correctly”?

Scott

I’m using Apache 2.2 / Mongrel / Typo edge - no problems (haven’t
sync’d since 4.0.2 went out).

On 8/16/06, Scott L. [email protected] wrote:

We ended up having to turn off caching to get it to work correctly. Anyone


Typo-list mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/typo-list


Cheers,

Kevin

“Any sufficiently advanced technology is indistinguishable from
Magic.” - Arthur C. Clarke

FWIW, I tracked down the leak–my new route cache wasn’t actually
working right, so it was losing 1 string per Article. Fixed :-). I
haven’t tested the trunk yet, or any of the admin pages.

Scott

Sorry would help to describe the issue wouldn’t it :slight_smile:

We were able to reproduce the mongrel issue with the out of the box 2.6.
one user adds a comment and the second user will not see it. I found
from
the logs that the page was being served up via the cache. I added a
logger
info message when the page was actually rendered. I wish I could give
you
step 1, step 2 directions but it seemed to be some sort of a race
condition.

I read through this http://scottstuff.net/presentations/rails-caching/
which
I though confirmed the issues with the before_filters. (hummm wonder who
that guy is :slight_smile:

In our specific app it is much easier to see, we added RBAC (Role Based
Access control). So a user has to log in before being able to see the
blog.
In the title we added “Welcome User Name”. User one logs in and sees
welcome User One. User two logs in and sees Welcome User One.
Sometimes
the user wasn’t even challenged to log in and somehow hijacked someone
else’s session.

When I cleared out the temp/cache/META directory then the problem would
go
away.

If you have time, lots of gory config details are here
http://forum.textdrive.com/viewtopic.php?pid=96574.

With the cache turned off speed is a little bit of an issue, however we
have
chosen to ignore that for now.

Hopefully you will tell me that I have something messed up in the
configuration.

-Linda