Hi,
After spending a good 12 hours to find out why something sloved down on all secondary runs, I found the problem stemmed from the fact that I was using Arrays for type fields.
On the first run everything is snappy, but on all secondary runs the allocation slows down. Tests have indicated that the first run is as much as 150% faster than secondary runs.
Additionally it seems to slow down over time to some extent.
I have now replaced the array field with statics, but it does result in messier code, because I have to use pointers to index values in some situations.
Here's a simple example that should demonstrate the problem:
You will also notice that the first clean up from the array type takes an excessive amount of time.
I assume this is all related to the fact that arrays are completely dynamic, so the field with arrays assigned can be resized at will. My suggestion/feature resuest is that a static option is added to the arrays, so they cannot be resized, and therefore act as regular variables. Like this:
After spending a good 12 hours to find out why something sloved down on all secondary runs, I found the problem stemmed from the fact that I was using Arrays for type fields.
On the first run everything is snappy, but on all secondary runs the allocation slows down. Tests have indicated that the first run is as much as 150% faster than secondary runs.
Additionally it seems to slow down over time to some extent.
I have now replaced the array field with statics, but it does result in messier code, because I have to use pointers to index values in some situations.
Here's a simple example that should demonstrate the problem:
SuperStrict Type TWithArray Global store:TWithArray[] Global index:Int Field abc:Float[3] Field def:Float[3] Function SetCount(count:Int) store = store[..count] index = 0 EndFunction Method New() store[index] = Self index:+1 abc[0] = 0.1 abc[1] = 0.2 abc[2] = 0.3 def[0] = 0.4 def[1] = 0.5 def[2] = 0.6 EndMethod Function Destroy() store = Null index = 0 EndFunction EndType Type TWithStatic Global store:TWithStatic[] Global index:Int Field abc0:Float,abc1:Float,abc2:Float Field def0:Float,def1:Float,def2:Float Function SetCount(count:Int) store = store[..count] index = 0 EndFunction Method New() store[index] = Self index:+1 abc0 = 0.1 abc1 = 0.2 abc2 = 0.3 def0 = 0.4 def1 = 0.5 def2 = 0.6 EndMethod Function Destroy() store = Null index = 0 EndFunction EndType Const loops:Int = 20 Const count:Int = 1000000 ' ' Create a lot of types array fields Print "~nTest with arrays" For Local i:Int = 0 Until loops TWithArray.SetCount(count) Local ms:Int = MilliSecs() For Local j:Int = 0 Until count New TWithArray Next ms = MilliSecs()-ms Local ms2:Int = MilliSecs() TWithArray.Destroy() GCCollect() ms2 = MilliSecs()-ms2 Print "Loop "+i+" MemAllocated: "+GCMemAlloced()+" Time: "+ms+"ms Cleaning: "+ms2 Next ' ' Create a lot of types with static fields Print "~nTest with statics" For Local i:Int = 0 Until loops TWithStatic.SetCount(count) Local ms:Int = MilliSecs() For Local j:Int = 0 Until count New TWithStatic Next ms = MilliSecs()-ms Local ms2:Int = MilliSecs() TWithStatic.Destroy() GCCollect() ms2 = MilliSecs()-ms2 Print "Loop "+i+" MemAllocated: "+GCMemAlloced()+" Time: "+ms+"ms Cleaning: "+ms2 Next
You will also notice that the first clean up from the array type takes an excessive amount of time.
I assume this is all related to the fact that arrays are completely dynamic, so the field with arrays assigned can be resized at will. My suggestion/feature resuest is that a static option is added to the arrays, so they cannot be resized, and therefore act as regular variables. Like this:
Field abc:Float[3] StaticWhich would make the compiler lock down the size of the array at compile time.