[Squeakfoundation]CSOTDs (was Re: ImageSegment analysis (was ...))

Dan Ingalls squeakfoundation@lists.squeakfoundation.org
Mon, 28 Jan 2002 09:59:56 -0800


>[This is ironic about mail lists -- this CSOTD stuff *definitely* shouldget=
 reposted to the Squeak-dev list.  maybe someone could forward a digest if=
 it keeps going (or not)]

> > > String streamContents: [:strm |
> > >		(ImageSegment new copyFromRootsForExport: Browser allInstances)
>> >					printSpaceAnalysisOn: strm]
>> > </CSOTD>
>>
> > Hehe! Go, go...

Yeah, Bijan!  That's pretty good (and so was Goran's!).  Way back when we=
 first did image segments, I did a space analysis too that simply gave the=
 size of the segment, so it corresponded more to 'space used' for the object=
 in question (I was looking at projects, and used the internal form, not the=
 export form).  I'm really glad to see you this deeply into image segments.

>Hmm. Now that I've posted this, I can ask: What *exactly* does it
>analyze? How deep does it go?
>
>Also, if I want to dump and image segment to disk and read it back in
>*not* as a project, how do I do it? Is it worth doing?
>
>I.e., I'm looking for code analogous to ReferenceStream's
>	rr _ ReferenceStream fileNamed: 'test.obj'.
>	rr nextPut: <your object>.
>	rr close.
>
>etc.
>
>I managed to dump a segment, but I'm completely unclear how to read one
>back in. Is there any point to using an ImageSegment over a
>ReferenceStream?

I once wrote all about image segments in a message around the time we got=
 them working.  It (or I think there were 2 or 3) should be in the archives=
 (and near the earliest mention of ImageSegment), and possibly in a=
 changeSet preamble, or the [updates] message that accompanied it.

To bypass, though, yes there are reasons to use an ImageSegment, the main=
 one being speed, esp if you are using it like a DLL.  I've forgotten=
 exactly, but I think I got it to load the entire VMConstruction category=
 (then about 500k with something like 20k objects) in less than 1/4 second.

One fruitful role ISs is to use them as a memory management technique for=
 many projects in a very large squeak image.  It lets you keep the run-time=
 footprint small (for GC speed and other reasons), but you can get to any=
 project in less than a second.

>(Don't have another CSOTD handy :))

CSOTD:  OK.  Here's one...

Given a list of email addresses, take them apart, and sort the groups by=
 number of people there (omitting the singletons):

(('fubar@yahoo.com
bazzfazz@yahoo.com
onions@google.com' findTokens: {Character cr})
	collect: [:x | x copyFrom: (x indexOf: $@) + 1 to: x size])
		asBag sortedCounts select: [:x | x key > 1]

This produces, for the Squeak-dev list, the following...
a SortedCollection(29->'yahoo.com' 18->'home.com' 17->'acm.org'=
 14->'aol.com' 11->'hotmail.com' 9->'mac.com' 9->'earthlink.net' 9->'mindspr=
ing.com' 8->'cc.gatech.edu' 7->'gmx.de' 6->'pobox.com' 6->'bellsouth.net'=
 5->'erols.com' 5->'t-online.de' 5->'sympatico.ca' 5->'netscape.net'=
 4->'iam.unibe.ch' 4->'ix.netcom.com' 4->'usa.net' 4->'bigfoot.com' 4->'worl=
dnet.att.net' 4->'squeakland.org' 4->'world.std.com' 4->'gemstone.com'=
 3->'san.rr.com' 3->'panix.com' 3->'cs.cmu.edu' 3->'gmx.net' 3->'uswest.net'=
 3->'microsoft.com' 3->'yahoo.com.ar' 3->'xs4all.nl' 3->'softhome.net'=
 3->'pacbell.net' 3->'mediaone.net' 2->'vianet.ca' 2->'core-sdi.com'=
 2->'rogers.com' 2->'compuserve.com' 2->'csn.net' 2->'ibm.net' 2->'telefonic=
a.com.ar' 2->'bluewin.ch' 2->'weird.com' 2->'free.fr' 2->'crear.com.ar'=
 2->'cmu.edu' 2->'well.com' 2->'instantiations.com' 2->'ping.de' 2->'whitest=
ein.com' 2->'media.mit.edu' 2->'info.unicaen.fr' 2->'bigpond.net.au' 2->'st.=
cs.uiuc.edu' 2->'ozemail.com.au' 2->'smalltalking.net' 2->'attglobal.net'=
 2->'umich.edu' 2->'mail.worldkey.net' 2->'appliedreasoning.com'=
 2->'msn.com' 2->'mail.com' 2->'espol.edu.ec' 2->'io.com' 2->'optushome.com.=
au' 2->'uiuc.edu' 2->'sprynet.com' 2->'arnet.com.ar' 2->'cogsci.ucsd.edu' 2-=
>'create.ucsb.edu' 2->'advantive.com' 2->'epost.de' 2->'heeg.de'=
 2->'inf.ufsc.br' 2->'telus.net' 2->'operamail.com' 2->'unx.sas.com'=
 2->'quallaby.com' 2->'open.ac.uk' 2->'disney.com' 2->'club-internet.fr' 2->=
'objectpeople.com' 2->'sra.co.jp' 2->'harlequin.co.uk' 2->'mail.sprint.com'=
 2->'gte.net' 2->'lineone.net' 2->'watson.ibm.com' 2->'cosmocows.com' 2->'im=
psat1.com.ar' 2->'lesser-software.com')