Performance of CGI::Cookie

B

benny

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)
 
B

benny

just saw this thread on google

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

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

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

benny

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)
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Performance of CGI::Cookie / SimpleDelegator fix"

|just saw this thread on google
|
|http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/117475
|
|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)
 
D

David Heinemeier Hansson

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_controller/
cgi_ext/cookie_performance_fix.rb
--
David Heinemeier Hansson,
http://www.basecamphq.com/ -- Web-based Project Management
http://www.rubyonrails.org/ -- Web-application framework for Ruby
http://macromates.com/ -- TextMate: Code and markup editor (OS X)
http://www.loudthinking.com/ -- Broadcasting Brain
 
T

Tom Copeland

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&func=browse

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top