On Sat, Nov 20, 2010 at 5:41 PM, Levente Uzonyi <[email protected]> wrote:
> On Sat, 20 Nov 2010, Mariano Martinez Peck wrote: > > On Sat, Nov 20, 2010 at 12:34 PM, Levente Uzonyi <[email protected]> wrote: >> >> On Fri, 19 Nov 2010, Mariano Martinez Peck wrote: >>> >>> In a 15MB image all CompiledMethods use only ~3MB, so this technique >>> won't >>> save much space IMHO. >>> >>> >>> mmmmm I thought it was muuuch more. How are you measuring those 3mb ? >> Only >> the compiled method bytearray or also the literals? Because if you take >> into >> account all the ByteSymbol instances of literals for example, the size can >> be more. >> > > That's just the methods themselves. I did some more experiments and I think > the savings can peak at ~5MB for the 15MB image. Now it sounds better :) More similar to my calculations....arround 1/3 part of the image. > > > >> >> >> To minimize the space usage, use SmallIntegers as proxies. To avoid the >>> (Object >> #hash) literals >>> >> >> >> #literals was an example, but the same happens with all the methods >> implemented in CompiledMethod. >> > > I also used #literals as an example. :) excellent > > > >> >> problem swap back the real method in MethodDictionary >> #at:ifAbsent:. >>> >>> >> Yes, actually Luc had this idea too. I should also modify (or implement) >> #at: and friends >> What I was afraid is if the VM directly access to them and I cannot >> interpret them. Is this possible? I think the vm access them but only >> when >> executing them....where in such case, it will end up with a #run:with:in, >> which is perfect for me. >> > > Normally the send ends up in #run:with:in:. > > Excellent. No problems then. > > >> >> A SmallInteger has 31 bits which can easily identify the file index and >> >>> position where the swapped out method is. For example you can use 7 bits >>> for >>> index and 24 bits for position. That allows you to have 128 files which >>> can >>> hold 16MB data each. >>> Or you can store a single method in a file, this way the SmallInteger >>> identifies the file. >>> >>> >> Yes, exactly :) >> >> Thanks Levente. I like this idea. I've been doing proxies for classes, >> normal objects, etc and I never thought about using SmallIntegers. This is >> because I usually need to do a #become: between the original object and >> the proxy. But in this case this is not needed, since I just need a >> methodDict at: put: . And this is a good idea because I don't need an >> object header per proxy instance. >> >> I will try to implement this. Thank you very much for all the answers. >> > > I did a quick implementation and it works. I am implementing right now :) > The only problem is that you can't swap-out a method that's used by the > swap-in code. > > Yes, but that's easy to solve. Before swapping everything, I "simulate" the swapping of a dummy CompiledMethod. During that, I mark all the CompiledMethods that were used to perform that. And then, I exclude those objects from being swapped :) > > Levente > > >> Mariano >> >> >> >>> >>> Levente >>> >>> >>> Thanks >>>> >>>> Mariano >>>> >>>> >>>> >>> >> >
