[Glass] Particular code that is much slower than Pharo
Mariano Martinez Peck via Glass
glass at lists.gemtalksystems.com
Tue Jan 24 11:42:11 PST 2017
Hi guys,
I have an algorithm which iterates a really large file (600k lines) and
then iterates quite some times. I found that in gemstone the process takes
4 times more than Pharo.... even if GemStone is running in a much better
hardware (server).
I tried to reproduce the issue (I am not sure if I succeeded in making the
below snipped to reproduce the exact same issue I have in the original
code), but at least I still see the 4x difference.
Please, do not pay much attention to the algorithm itself. Getting a 50%
for THIS particular problem won't help me much as I may find these kind of
issues on other places. So I would love to see if there is some general
speedup I am missing. In other words, I would like to understand WHY it is
slower than Pharo.
For the details, I am in GemStone 3.2.9, running in Linux, 2GB SPC, etc.
Native code is enabled.
If I profile the code on GemStone I see there is a slowdown in:
86.2% (256) SequenceableCollection >> doWithIndex: [Array]
| 80.1% (238) block in executed code [ExecBlock2]
| | 40.1% (119) Array >> at:
| | 16.8% (50) SmallInteger >> =
| | 0.7% (2) OrderedCollection >> add:
| | 0.3% (1) Array >> at:put:
| | 0.3% (1) SmallInteger >> <=
| 3.7% (11) Array >> at:
So...it looks to me that Array >> at: and SmallInteger >> = take like 45%
of the time....so I guess I cannot improve that.
Thank you very much in advance.
-----------
The code is this:
| array1 another |
array1 := #( 1 2 3 4 5 6 7 8 9).
another := #(8 9 10 11 12 115 9 116 117 16 118).
10000 timesRepeat: [
| answer i j selfSize anotherSize skipTestsTable |
answer := OrderedCollection new.
skipTestsTable := array1 collect: [ :each | Array new: another size ]. "all
nils"
selfSize := array1 size.
anotherSize := another size.
array1 doWithIndex: [:each :selfStart |
| skipTableAtStart |
skipTableAtStart := skipTestsTable at: selfStart.
1 to: anotherSize do: [ :anotherStart|
(false or: [ (skipTableAtStart at: anotherStart) isNil]) ifTrue: [
each = (another at: anotherStart)
ifTrue: [
i := selfStart + 1.
j := anotherStart + 1.
[ (i <= selfSize and: [ j <= anotherSize ]) and: [ (array1 at: i) =
(another at: j)]]
whileTrue: [
(skipTestsTable at: i) at: j put: true.
i := i + 1.
j := j + 1. ].
answer add: { selfStart. anotherStart. (i - selfStart). i - 1 }
] ]
]
].
answer asArray
]
] timeToRun
--
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20170124/6bd34cf3/attachment.html>
More information about the Glass
mailing list