From: Lennon Day-Reynolds Date: 2004-07-03T08:15:31+09:00 Subject: Re: slow method searching? I think I found it: eval.c from ruby-1.8.1, in 'method_missing', lines 4908-4910 nargv = ALLOCA_N(VALUE, argc+1); nargv[0] = ID2SYM(id); MEMCPY(nargv+1, argv, VALUE, argc); At that point, the 'argv' array includes the object on which the method lookup failed. So, the 'method_missing' throw includes a bulk memory copy of the object contents. I'm not sure why it would work that way instead of just returning another reference to the same object, but there must be some reason. Lennon On Sat, 3 Jul 2004 08:01:16 +0900, Carlos wrote: > > [David Garamond , 2004-07-02 23.56 CEST] > > $ time ruby -e'a=(1..200000).to_a; a.classx' > > -e:1: undefined method `classx' for # (NoMethodError) > > > > real 0m3.768s > > user 0m1.640s > > sys 0m0.010s > > > > $ time ruby -e'a=(1..200000).to_a; b=nil; b.classx' > > -e:1: undefined method `classx' for nil:NilClass (NoMethodError) > > In my computer, there is a noticeable delay between the "-e:1" and the rest > of the exception message. > > During that time, there is a lot of "mremap" system calls whose meaning I > don't know (GC? OS swapping(?)? A very long longjmp(!?)?). > > Before I paste the last lines of the strace, which show the mremaps, I will > write yet another paragraph (this), because if I'm going to waste internet > bandwidth with non-answers, I'll do it good :). > > write(2, "-e:1", 4) = 4 > brk(0) = 0x8158000 > brk(0x8187000) = 0x8187000 > mmap2(NULL, 270336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) > = 0x402d1000 > brk(0) = 0x8187000 > brk(0) = 0x8187000 > brk(0x816b000) = 0x816b000 > brk(0) = 0x816b000 > mremap(0x402d1000, 270336, 536576, MREMAP_MAYMOVE) = 0x402d1000 > mremap(0x402d1000, 536576, 536576, MREMAP_MAYMOVE) = 0x402d1000 > mremap(0x402d1000, 536576, 1069056, MREMAP_MAYMOVE) = 0x402d1000 > mremap(0x402d1000, 1069056, 1069056, MREMAP_MAYMOVE) = 0x402d1000 > mremap(0x402d1000, 1069056, 2134016, MREMAP_MAYMOVE) = 0x402d1000 > write(2, ": ", 2) = 2 > write(2, "undefined method lassx\' for #<"..., 49) = 49 > write(2, " (", 2) = 2 > write(2, "NoMethodError", 13) = 13 > write(2, ")\n", 2) = 2 > exit_group(1) = ? > > Good luck. > >