[Pharo-project] Speeding up Finder string search
Mariano Martinez Peck
marianopeck at gmail.com
Tue Jan 17 03:47:34 EST 2012
Stefan, another approach would be to store the source code in the compiled
method trailer. That way you don't need the IdentityDictionary nor
searching anything. Just store the source in there. Since a couple of
releases, CompiledMethodTrailer is reified and you can have custom types of
trailers. Check methods like #encodeEmbeddedSourceQCompress and
#decodeEmbeddedSourceQCompress etc... not sure if everything is working,
but I am sure that the CompiledMethodTrailer "architecture" is working and
it should be really easy to be able to store sources there.
PS: I will interested if you do it :)
On Mon, Jan 16, 2012 at 10:07 PM, Stefan Marr <smalltalk at stefan-marr.de>wrote:
> On 16 Jan 2012, at 14:50, Stefan Marr wrote:
> > Hi:
> > On 16 Jan 2012, at 14:31, Camillo Bruni wrote:
> >> I guess having the sources completely in the image is the
> straight-forward solution to this :/
> > Well, we could also cache just the resulting source string.
> > Not sure what that means in terms of memory, but going to the file every
> time a method is asked for its code seems to be very naive.
> I put a cache (IdentityDictionary) methodSource into Class. That requires
> recompiling all classes which takes a while, and I do not know, whether it
> should not be in ClassDescription.
> And guess what:
> The bad news: the image size doubles from 22.2MB to 39.5MB.
> The good news:
> "before using cache" #(43239 23490 22084) #(20581 20238 20207)
> The 43239 created all dictionaries.
> "warming up and using cache"
> #(20177 1428 1393) #(1389 1374 1400)
> That is a pretty nice speedup, grep is still a faster, but now finder
> becomes usable!
> I use the cache like this:
> "Read the source code from file, determining source file index and
> file position from the last 3 bytes of this method."
> | position classSrc |
> classSrc := self methodClass getSourceFor: self selector.
> classSrc ifNotNil: [
> ^ classSrc].
> (position := self filePosition) = 0 ifTrue: [^ nil].
> classSrc := (RemoteString newFileNumber: self fileIndex position:
> position) string.
> self methodClass setSourceFor: self selector to: classSrc.
> ^ classSrc
> To me that feels all pretty straight forward and naive, so feel free to
> have better ideas.
> Perhaps the cache should get evicted when not used, etc...
> Best regards
> Stefan Marr
> Software Languages Lab
> Vrije Universiteit Brussel
> Pleinlaan 2 / B-1050 Brussels / Belgium
> Phone: +32 2 629 2974
> Fax: +32 2 629 3525
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pharo-dev