[squeak-dev] Odd performance characteristics of symbol creation
Adrian Lienhard
alienhard at netstyle.ch
Wed May 6 16:28:21 UTC 2009
Hi,
We have a server application that, after some longer usage, becomes
very slow. It turned out that this is because lots of symbols are
created from strings (without holding onto them), which becomes slower
and slower over time. This is easy to fix in our app, but I'd like to
understand why Squeak has a problem with that.
Using the following snipped, I produced the attached chart (Y axis is
ms spent to create 5000 random symbols). You can nicely see the
reoccurring pattern that grows over time.
1000 timesRepeat: [
Transcript print: ([
5000 timesRepeat: [ (($a to: $x) atRandom asString , 'asdasd')
asSymbol ] ] timeToRun); cr; flush. ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Picture 2.png
Type: image/png
Size: 13753 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20090506/4c2e7be1/Picture2.png
-------------- next part --------------
Message tally sais:
96.2% {13872ms} ByteString(String)>>asSymbol
|96.2% {13872ms} Symbol class>>intern:
| 49.7% {7167ms} Symbol class>>lookup:
| |49.7% {7167ms} WeakSet>>like:
| | 49.7% {7167ms} WeakSet>>scanFor:
| | 32.3% {4658ms} primitives
| | 17.3% {2495ms} UndefinedObject(Object)>>=
| 44.4% {6402ms} WeakSet>>add:
| |44.3% {6388ms} WeakSet(Set)>>findElementOrNil:
| | 44.3% {6388ms} WeakSet>>scanFor:
| | 22.8% {3288ms} UndefinedObject(Object)>>=
| | 21.5% {3100ms} primitives
| 2.1% {303ms} ByteSymbol>>string:
2.9% {418ms} Character>>to:
2.4% {346ms} SmallInteger(Number)>>to:
2.4% {346ms} Interval class>>from:to:by:
2.4% {346ms} Interval>>setFrom:to:by:
I haven't had time to look into this very closely yet but maybe
somebody else already knows what is going on. My guess is that the
NewSymbols weak set is repeatedly grown since tally is not decreased
if the GC removes a weak element.
This is a Squeak 3.9 image (OS X and Linux).
Cheers,
Adrian
___________________
http://www.adrian-lienhard.ch/
More information about the Squeak-dev
mailing list
|