[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Performance of CGI::Cookie

benny

2/7/2005 2:44:00 PM

dear list

just discovered that the CGI::Cookie class has a major impact on
performance.

When using it, ab gives me (using fcgi/apache 1.3)

40.85 Requests / second

when simplifying the initialization of CGI::Cookie (see below), its 3 times
faster:

124.64 Requests / second

Perhaps someone should dig in this. It seems to be related to the
SimpleDelegator superclassing (though I don't see why delegating should be
necessary here, the simplification seems to work fine).

benny

--

class CGI
class Cookie
def initialize(options)
unless options.has_key?("name")
raise ArgumentError, "`name' required"
end

@name = options["name"]
@value = Array(options["value"])

# simple support for IE
if options["path"]
@path = options["path"]
else
%r|^(.*/)|.match(ENV["SCRIPT_NAME"])
@path = ($1 or "")
end

@domain = options["domain"]
@expires = options["expires"]
@secure = options["secure"] == true ? true : false
end
end
end


--
---------------------------------------------------------------------------------------------------
Don't crash when a filter changes the subject of a message which results
in the attempt to remove it from the tree of subject threading messages
failing and the detached child looking for a new parent finding the old
parent as the new parent, which in turn results in the child being deleted
with the old (and new) parent, which is not a good idea, since it is
still referenced.

(Till Adams commit on kdepim/kmail/kmheaders.cpp in HEAD, 6. Jan. 2005)
4 Answers

benny

2/7/2005 6:07:00 PM

0

just saw this thread on google

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t...

apparently this fix didn't make it into ruby 1.8.2:

ruby --version
ruby 1.8.2 (2004-12-25) [i386-freebsd5]

benny


benny wrote:

> dear list
>
> just discovered that the CGI::Cookie class has a major impact on
> performance.
>
> When using it, ab gives me (using fcgi/apache 1.3)
>
> 40.85 Requests / second
>
> when simplifying the initialization of CGI::Cookie (see below), its 3
> times faster:
>
> 124.64 Requests / second
>
> Perhaps someone should dig in this. It seems to be related to the
> SimpleDelegator superclassing (though I don't see why delegating should be
> necessary here, the simplification seems to work fine).
>
> benny
>
> --
>
> class CGI
> class Cookie
> def initialize(options)
> unless options.has_key?("name")
> raise ArgumentError, "`name' required"
> end
>
> @name = options["name"]
> @value = Array(options["value"])
>
> # simple support for IE
> if options["path"]
> @path = options["path"]
> else
> %r|^(.*/)|.match(ENV["SCRIPT_NAME"])
> @path = ($1 or "")
> end
>
> @domain = options["domain"]
> @expires = options["expires"]
> @secure = options["secure"] == true ? true : false
> end
> end
> end
>
>

--
---------------------------------------------------------------------------------------------------
Don't crash when a filter changes the subject of a message which results
in the attempt to remove it from the tree of subject threading messages
failing and the detached child looking for a new parent finding the old
parent as the new parent, which in turn results in the child being deleted
with the old (and new) parent, which is not a good idea, since it is
still referenced.

(Till Adams commit on kdepim/kmail/kmheaders.cpp in HEAD, 6. Jan. 2005)

Yukihiro Matsumoto

2/8/2005 12:33:00 AM

0

Hi,

In message "Re: Performance of CGI::Cookie / SimpleDelegator fix"
on Tue, 8 Feb 2005 03:10:09 +0900, benny <listen@marcrenearns.de> writes:

|just saw this thread on google
|
|http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t...
|
|apparently this fix didn't make it into ruby 1.8.2:

I will merge the fix to 1.8. Apply the patch or wait for 1.8.3
(which will be released in April, hopefully).

matz.

--- lib/cgi.rb 1 Nov 2004 23:53:48 -0000 1.68.2.9
+++ lib/cgi.rb 8 Feb 2005 00:32:29 -0000
@@ -772,3 +772,3 @@ class CGI
# cookie1.secure = true
- class Cookie < SimpleDelegator
+ class Cookie < DelegateClass(Array)



David Heinemeier Hansson

2/9/2005 1:23:00 PM

0

> Perhaps someone should dig in this. It seems to be related to the
> SimpleDelegator superclassing (though I don't see why delegating
> should be
> necessary here, the simplification seems to work fine).

I made a post about this before the release of 1.8.2, but unfortunately
it didn't make it in for some reason. Rails ships with a
cookie_performance_fix.rb[1] file for this very reason. Hopefully this
will be picked up and be part of the next release.

Ruby could really use a Trac installation to keep track of patches (and
bugs).

[1]
http://dev.rubyonrails.com/file/trunk/actionpack/lib/action_c...
cgi_ext/cookie_performance_fix.rb
--
David Heinemeier Hansson,
http://www.basec... -- Web-based Project Management
http://www.rubyon... -- Web-application framework for Ruby
http://macro... -- TextMate: Code and markup editor (OS X)
http://www.loudthi... -- Broadcasting Brain



Tom Copeland

2/9/2005 2:19:00 PM

0

On Wed, 2005-02-09 at 08:22, David Heinemeier Hansson wrote:
> > Perhaps someone should dig in this. It seems to be related to the
> > SimpleDelegator superclassing (though I don't see why delegating
> > should be
> > necessary here, the simplification seems to work fine).
>
> I made a post about this before the release of 1.8.2, but unfortunately
> it didn't make it in for some reason. Rails ships with a
> cookie_performance_fix.rb[1] file for this very reason. Hopefully this
> will be picked up and be part of the next release.
>
> Ruby could really use a Trac installation to keep track of patches (and
> bugs).

Hm, there's the RubyForge "ruby" project bug tracker here:

http://rubyforge.org/tracker/?atid=1698&group_id=426&f...

and the patch tracker on that project as well.

Bugs and patches submitted there automatically generate an email to the
ruby-core mailing list...

Yours,

Tom