D
David Heinemeier Hansson
Just like Tempfile, CGI::Cookie uses SimpleDelegator. This causes a
massive performance overhead for mod_ruby/FCGI based sites. I did a
profile on 50 requests through a simple Rails that recorded 26,000
calls to String.===, which SimpleDelegator was responsible for.
The fix is exactly the same as what Matz recommended for Tempfile in:
http://groups.google.com/groups?
th=e3a4e68ba042f842&seekm=c3sioe%241qvm%241%40news.cybercity.dk#link14
-class CGI::Cookie < SimpleDelegator
+class CGI::Cookie < DelegateClass(Array)
+ def __setobj__(obj)
+ @_dc_obj = obj
+ end
I hope this change can make it into Ruby 1.8.2. For now, Rails (0.8)
will include a custom CGI::Cookie with these changes. The fixed version
gives about 100% more performance on some cases.
--
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
massive performance overhead for mod_ruby/FCGI based sites. I did a
profile on 50 requests through a simple Rails that recorded 26,000
calls to String.===, which SimpleDelegator was responsible for.
The fix is exactly the same as what Matz recommended for Tempfile in:
http://groups.google.com/groups?
th=e3a4e68ba042f842&seekm=c3sioe%241qvm%241%40news.cybercity.dk#link14
-class CGI::Cookie < SimpleDelegator
+class CGI::Cookie < DelegateClass(Array)
+ def __setobj__(obj)
+ @_dc_obj = obj
+ end
I hope this change can make it into Ruby 1.8.2. For now, Rails (0.8)
will include a custom CGI::Cookie with these changes. The fixed version
gives about 100% more performance on some cases.
--
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