ERuby speed issues 
Author Message
 ERuby speed issues

We have been running eruby for a couple of months now, and have found that
it is extremely slow, taking up to a minute to load a simple page.

Having run the ruby profiler, I have found that the two things that take the
longest time are: #toplevel and Kernel.require.

Being relatively new to Ruby, I am wanting to confirm what #toplevel is. If
I understand correctly, #toplevel is just any code that runs without being
in a class, method, or other type of "container", if you will.

I am also wondering about the Kernel.require speed; is that just because it
is accessing the file system? It looks like eruby.import commands take about
as long.

Thanks for your help.

Peter Pallock



Sun, 10 Apr 2005 00:58:17 GMT  
 ERuby speed issues

Quote:
> We have been running eruby for a couple of months now, and have found that
> it is extremely slow, taking up to a minute to load a simple page.

> Having run the ruby profiler, I have found that the two things that take
> the longest time are: #toplevel and Kernel.require.

> Being relatively new to Ruby, I am wanting to confirm what #toplevel is. If
> I understand correctly, #toplevel is just any code that runs without being
> in a class, method, or other type of "container", if you will.

> I am also wondering about the Kernel.require speed; is that just because it
> is accessing the file system? It looks like eruby.import commands take
> about as long.

> Thanks for your help.

> Peter Pallock

Up to a *minute*? That seems a little excessive for a simple page; I ran eRuby
for well over a year w/out any similar problems (I currently recoding in
amrita).  Can you post some example code with timing?

~ Bruce



Sun, 10 Apr 2005 07:21:16 GMT  
 ERuby speed issues
The below code is being run on an Apache webserver with ModRuby 0.97. (I
have also tried running it straight CGI, versus ModRuby.) Despite the
numbers from the Ruby profiler (which are below the code), this particular
page loads in no less than 8 seconds and up to 1 minute. This is when I go
to the page the first time, not even when I submit the form.

<%
require 'cgi'
require 'digest/md5'
require 'iblp/iblp_login/loginsession.rb'
include LoginManager

session = LoginSession.new
cgi = CGI.new

if session.valid_session? then # This checks a cookie value
        error_message = "You are now logged in."
        logged_in = true
else
        error_message = "Please log in below."

        if ENV.include?("HTTPS") then
                if ENV["REQUEST_METHOD"] == "POST" then
                        require "iblp/iblp_login/entity/login"

                        login_broker =
Entity::LoginBroker.new(Storage::ConnectionBroker.new)
                        login =
login_broker.fetch_login(cgi.params["username"].to_s,
cgi.params["password"].to_s)

                        if login.trusted?
                                if session.new_session(login.entity_id) then
                                        if cgi.cookies.include?("referer")
then
                                                cgi.header("Location" =>
cgi.cookies["referer"].value.to_s)
                                        end

                                        logged_in = true
                                        error_message = "You are now logged
in."
                                else
                                        error_message = "Session could not
be created."
                                end
                        else
                                error_message = "Invalid username or
password. Please try again."
                        end
                end
        else
                session.set_secure("https://bob.iblp.net") # This does a CGI
header redirect
        end
end

%>

<html>
<head>
        <title>Login</title>
        <link rel="stylesheet" href="include/style.css" type="text/css">
</head>
<!-- Begin Header -->
<% ERuby.import "include/header.rhtml" %>
<!-- End Header -->
<!-- Begin Content -->

<br />
<center>
<form method="post" name="login" action="login.rhtml">
<!-- In here was a simple login form -->
</form>
</center>

<!-- End Content -->
<!-- Begin Footer -->
<% ERuby.import "include/footer.rhtml" %>
<!-- End Footer -->
</html>

  %   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
 53.95     0.41      0.41       10    41.00   108.00  Kernel.require
 32.89     0.66      0.25        2   125.00   520.00  Class#new
 15.79     0.78      0.12        8    15.00    28.75  Array#each
  5.26     0.82      0.04      171     0.23     0.23  Module#method_added
  5.26     0.86      0.04       28     1.43     1.43  String#downcase
  3.95     0.89      0.03       64     0.47     0.47  Fixnum#to_s
  2.63     0.91      0.02       45     0.44     0.44
Kernel.singleton_method_added
  2.63     0.93      0.02       16     1.25     1.88  Module#module_eval
  1.32     0.94      0.01        6     1.67    26.67  Date#once
  1.32     0.95      0.01        1    10.00    10.00  Module#include
  1.32     0.96      0.01       22     0.45     0.45  Module#private
  1.32     0.97      0.01       28     0.36     0.36  Kernel.eval
  1.32     0.98      0.01        1    10.00    10.00  IO#print
  1.32     0.99      0.01        1    10.00    10.00  Kernel.extend
  1.32     1.00      0.01        1    10.00    10.00  Regexp#match
  0.00     1.00      0.00        1     0.00    30.00
CGI::QueryExtension.initialize_query
  0.00     1.00      0.00        1     0.00    40.00  CGI#initialize
  0.00     1.00      0.00        2     0.00     0.00  ENV.[]
  0.00     1.00      0.00        1     0.00     0.00  Kernel.at_exit
  0.00     1.00      0.00       28     0.00     0.00  String#sub
  0.00     1.00      0.00        1     0.00     0.00  IO#write
  0.00     1.00      0.00        3     0.00     0.00  String#===
  0.00     1.00      0.00        2     0.00     0.00  Module#append_features
  0.00     1.00      0.00        1     0.00     0.00  Module#extend_object
  0.00     1.00      0.00        1     0.00     0.00  Module#attr_reader
  0.00     1.00      0.00        9     0.00     0.00  Class#inherited
  0.00     1.00      0.00        1     0.00     0.00  String#<=>
  0.00     1.00      0.00        1     0.00    30.00
CGI::QueryExtension.read_from_cmdline
  0.00     1.00      0.00        1     0.00     0.00
Exception#set_backtrace
  0.00     1.00      0.00       32     0.00     0.00  Symbol#id2name
  0.00     1.00      0.00        1     0.00    40.00
LoginManager::LoginSession#initialize
  0.00     1.00      0.00       64     0.00     0.00  Symbol#to_i
  0.00     1.00      0.00        1     0.00     0.00  Module#attr
  0.00     1.00      0.00        1     0.00     0.00  Kernel.readlines
  0.00     1.00      0.00        1     0.00     0.00  Array#+
  0.00     1.00      0.00        1     0.00     0.00  main.include
  0.00     1.00      0.00        1     0.00     0.00  IO#tty?
  0.00     1.00      0.00       23     0.00     0.00  Module#alias_method
  0.00     1.00      0.00        2     0.00     0.00  CGI#env_table
  0.00     1.00      0.00        1     0.00     0.00  String#+
  0.00     1.00      0.00        2     0.00     5.00  Module#attr_accessor
  0.00     1.00      0.00        1     0.00     0.00  Comparable.<
  0.00     1.00      0.00        1     0.00     0.00  Module#module_function
  0.00     1.00      0.00        1     0.00   760.00  #toplevel
  0.00     1.00      0.00        2     0.00     0.00  String#==
  0.00     1.00      0.00        2     0.00     0.00  Exception#backtrace
  0.00     1.00      0.00        1     0.00     0.00  Array#empty?

Quote:
-----Original Message-----


> We have been running eruby for a couple of months now, and have found that
> it is extremely slow, taking up to a minute to load a simple page.

> Having run the ruby profiler, I have found that the two things that take
> the longest time are: #toplevel and Kernel.require.

> Being relatively new to Ruby, I am wanting to confirm what #toplevel is.
If
> I understand correctly, #toplevel is just any code that runs without being
> in a class, method, or other type of "container", if you will.

> I am also wondering about the Kernel.require speed; is that just because
it
> is accessing the file system? It looks like eruby.import commands take
> about as long.

> Thanks for your help.

> Peter Pallock

Up to a *minute*? That seems a little excessive for a simple page; I ran
eRuby
for well over a year w/out any similar problems (I currently recoding in
amrita).  Can you post some example code with timing?

~ Bruce



Sun, 10 Apr 2005 21:42:42 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ERuby speed issues

2. XP Speed Issues

3. Speed issues

4. File Access mode / speed issue

5. building a queue - speed issue

6. MS SQL - Record Size - Speed Issue

7. ModelSim XE/Starter speed issues

8. Lahey & Intel compilation size/speed issues

9. Yet another Python vs. Perl speed issue/question

10. Speed issues

11. Python Berkley DB and speed issues

12. Python speed issue

 

 
Powered by phpBB® Forum Software