GzipReader problem

Thank you for the fix.

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.

I measured using this (reading from a non-gzipped file):

class IO
alias :_old_read :read
@@x = Hash.new
def read(n)
@@x[n] ||= 0
@@x[n] += 1
_old_read(n)
end

def IO.showx
@@x.sort.each {|v| print v[0]," - ",v[1],"\n"}
print "Total:",@@x.inject(0) {|s,n| s+=n[1]},"\n"
end
end

And here is the result after reading the object in using Marshal:

bytes requested - number of reads

0 - 39322
3 - 10074
4 - 160
5 - 113
6 - 10
7 - 14
8 - 10175
9 - 10224
10 - 10314
11 - 1129
12 - 4114
13 - 4696
14 - 27
15 - 7
16 - 15
17 - 4
18 - 8
19 - 2
22 - 3
23 - 1
24 - 6
25 - 4
26 - 3
27 - 7
28 - 5
29 - 18
30 - 23
31 - 24
32 - 19
33 - 28
34 - 13
35 - 17
37 - 2
38 - 4
39 - 1
42 - 2
45 - 7
51 - 2
55 - 2
66 - 3
Total:90602

I can't see what is causing Marshal to behave so. In other cases
Marshal seems to read everything in in just a couple of gulps.

I will try to reduce the example size to figure out the reason for it.

Stephen

Tanaka Akira wrote:

In article <cenm45$4gg@odak26.prod.google.com>,
  "StephenSykes" <jbshaldane@hotmail.com> writes:

....

> This wouldn't normally matter, but Marshal sometimes tries to read

0

> bytes during its work for some reason which I am trying to

investigate

···

> (anyone know what circumstances would cause marshal to do that?)
> Regards,

Interesting example.

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.

Note that I don't think empty regexps and bignum zeros are used so
frequently.

···

--
Tanaka Akira