MenTaLguY wrote:
> On Fri, 22 Jun 2007 06:47:22 +0900, Aaron Smith 
> <beingthexemplary / gmail.com> wrote:
>> Thanks, Yes I have the ruby application RubyAMF already done. But I'm
>> trying to optimize the AMF de/serialization and figured C would be the
>> best solution. So now I just need write the C instead of worrying about
>> Ruby/AMF integration.. Once the C is working, tie that back into
>> Ruby/AMF.
> 
> Ah, {de,}serialization code is one of those places where C is more often 
> helpful.
> 
> That said, have you done profiling and taken advantage of all of the
> pure Ruby optimization opportunities you've had first?
> 
> Performance bottlenecks can happen in very unexpected places, and 
> heavily optimizing
> one part of the code won't help you much if 90% of the execution time is 
> happening
> in a different part.
> 
> Another question to consider is if you are interested in supporting 
> other Ruby
> implementations (e.g. JRuby or Ruby.NET).  If so, then it's best to 
> minimize the
> amount of code you push into C.
> 
> Along those lines, profiling may highlight one or two specific methods 
> that need
> to be done in C, versus rewriting a large part of the application.
> 
> -mental

Hm. I haven't thought about JRuby or Ruby.NET. Don't know if it's 
something I should worry about. I've done some profiling and overall the 
application is pretty well tuned. The times when the application 
performs slowly is when returning thousands of records from mysql. When 
it's in the serializing code.

Here are a couple ruby-prof call graphs that illustrate the timeliness 
of mysql VS returning a string

returning 3000 mysql records:
http://blog.rubyamf.org/profiling/serialize/mysql_3000_flat.txt
http://blog.rubyamf.org/profiling/serialize/mysql_3000_graph.txt

returning 1 string:
http://blog.rubyamf.org/profiling/serialize/string_flat.txt
http://blog.rubyamf.org/profiling/serialize/string_graph.txt

returning some number
http://blog.rubyamf.org/profiling/serialize/bignum_flat.txt
http://blog.rubyamf.org/profiling/serialize/fixnum_flat.txt
http://blog.rubyamf.org/profiling/serialize/float_flat.txt

You can start to see processing times increase in the mysql one at the 
end of flat version.. Take a look, let me know what you think. I think 
the performance gains would definitely be seen writing the 
de/serializers with C..

Thanks for talking shop.
-Aaron

-- 
Posted via http://www.ruby-forum.com/.