Tanaka Akira wrote:
> In article <ceorhk$1cl / odak26.prod.google.com>,
>   "StephenSykes" <jbshaldane / hotmail.com> writes:
>
> > The failing example is indeed interesting.  My marshalled object is
> > 1.2Mb uncompressed.  And Marshal uses over 90,000 reads requests to
> > read it.  And nearly 40,000 of those requests are for 0 bytes.
>
> As reading marshal.c, it seems that read(0) is called with an empty
> string (""), an empty regexp (//) and a bignum zero
> (0x40000000.coerce(0)[0]).
>
> So I guess you have nearly 40,000 empty strings.

Yes, I had come to the same conclusion myself.  They are empty strings.
Marshal could perhaps optimise away this case.

Incidently, all those little reads for all my little strings makes
using GzipReader very slow.  If I read my compressed file into a string
first, and pass that to Marshal.load, it loads up in less than half a
second.  But if I pass GzipReader directly to Marshal (with your fix)
then loading takes about 30 seconds.

Stephen