> Yes, this is my problem, too. > I need an efficient way to transfer data model, but it seems that drb is > not just "transfer". > Even if I ignore the object size thing, still, calling a drbObject's > complex method is an issue. DRb uses Marshal to convert objects into a stream of bytes. It then adds a tiny wrapper (basically 4 bytes giving the length) So if you want to see how big an object is when sent via DRb, just use Marshal explicitly: irb(main):001:0> class Test; attr_accessor :foo; end => nil irb(main):002:0> a = Test.new; a.foo = ["this", "thing"] => ["this", "thing"] irb(main):003:0> b = Marshal.dump(a) => "\004\010o:\tTest\006:\t@foo[\a\"\tthis\"\nthing" irb(main):004:0> b.size => 31 irb(main):005:0> c = Marshal.load(b) => #<Test:0xb7cc2994 @foo=["this", "thing"]> irb(main):006:0> In the above example, b contains the marshalled version of object a, which in turn contains another object (an array), which in turn contains two strings. As you can see, this entire compound object takes 31 bytes on the wire. HTH, Brian.
on 2007-07-17 12:02