aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2019-11-22 04:09:05 +0000
committerUbitUmarov2019-11-22 04:09:05 +0000
commit9b7ad30ee12ee027be6cd93d4e17d67cf0b65966 (patch)
treeb65bb712629d9810c382a0f34e718af9107a6cd8 /OpenSim/Region
parentcosmetics (diff)
downloadopensim-SC-9b7ad30ee12ee027be6cd93d4e17d67cf0b65966.zip
opensim-SC-9b7ad30ee12ee027be6cd93d4e17d67cf0b65966.tar.gz
opensim-SC-9b7ad30ee12ee027be6cd93d4e17d67cf0b65966.tar.bz2
opensim-SC-9b7ad30ee12ee027be6cd93d4e17d67cf0b65966.tar.xz
more changes on YEngine scripts heap usage
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs15
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/XMRHeapTracker.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs62
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/XMRSDTypeClObj.cs2
6 files changed, 54 insertions, 45 deletions
diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs
index 83ccd9b..67348cf 100644
--- a/OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs
@@ -69,15 +69,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine
69 { 69 {
70 this.inst = inst; 70 this.inst = inst;
71 dnary = new SortedDictionary<object, object>(XMRArrayKeyComparer.singleton); 71 dnary = new SortedDictionary<object, object>(XMRArrayKeyComparer.singleton);
72 heapUse = inst.UpdateHeapUse(0, EMPTYHEAP); 72 heapUse = inst.UpdateArraysHeapUse(0, EMPTYHEAP);
73 } 73 }
74 74
75 /* 75
76 ~XMR_Array() 76 ~XMR_Array()
77 { 77 {
78 heapUse = inst.UpdateHeapUse(heapUse, 0); 78 heapUse = inst.UpdateLocalsHeapUse(heapUse, 0);
79 } 79 }
80 */
81 80
82 public static TokenType GetRValType(TokenName name) 81 public static TokenType GetRValType(TokenName name)
83 { 82 {
@@ -123,7 +122,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
123 { 122 {
124 newheapuse += keysize + HeapTrackerObject.Size(value); 123 newheapuse += keysize + HeapTrackerObject.Size(value);
125 } 124 }
126 heapUse = inst.UpdateHeapUse(heapUse, newheapuse); 125 heapUse = inst.UpdateArraysHeapUse(heapUse, newheapuse);
127 126
128 // Save new value in array, replacing one of same key if there. 127 // Save new value in array, replacing one of same key if there.
129 // null means remove the value, ie, script did array[key] = undef. 128 // null means remove the value, ie, script did array[key] = undef.
@@ -185,7 +184,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
185 */ 184 */
186 public void __pub_clear() 185 public void __pub_clear()
187 { 186 {
188 heapUse = inst.UpdateHeapUse(heapUse, EMPTYHEAP); 187 heapUse = inst.UpdateArraysHeapUse(heapUse, EMPTYHEAP);
189 dnary.Clear(); 188 dnary.Clear();
190 enumrValid = false; 189 enumrValid = false;
191 arrayValid = 0; 190 arrayValid = 0;
@@ -286,7 +285,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
286 public delegate object RecvArrayObjDelegate(); 285 public delegate object RecvArrayObjDelegate();
287 public void RecvArrayObj(RecvArrayObjDelegate recvObj) 286 public void RecvArrayObj(RecvArrayObjDelegate recvObj)
288 { 287 {
289 heapUse = inst.UpdateHeapUse(heapUse, EMPTYHEAP); 288 heapUse = inst.UpdateArraysHeapUse(heapUse, EMPTYHEAP);
290 // Cause any enumeration to refill the array from the sorted dictionary. 289 // Cause any enumeration to refill the array from the sorted dictionary.
291 // Since it is a sorted dictionary, any enumerations will be in the same 290 // Since it is a sorted dictionary, any enumerations will be in the same
292 // order as on the sending side. 291 // order as on the sending side.
@@ -301,7 +300,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
301 object key = FixKey(recvObj()); 300 object key = FixKey(recvObj());
302 object val = recvObj(); 301 object val = recvObj();
303 int htuse = HeapTrackerObject.Size(key) + HeapTrackerObject.Size(val); 302 int htuse = HeapTrackerObject.Size(key) + HeapTrackerObject.Size(val);
304 heapUse = inst.UpdateHeapUse(heapUse, heapUse + htuse); 303 heapUse = inst.UpdateArraysHeapUse(heapUse, heapUse + htuse);
305 dnary.Add(key, val); 304 dnary.Add(key, val);
306 } 305 }
307 } 306 }
diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRHeapTracker.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRHeapTracker.cs
index 1797c93..f3e38c4 100644
--- a/OpenSim/Region/ScriptEngine/YEngine/XMRHeapTracker.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/XMRHeapTracker.cs
@@ -106,9 +106,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine
106 public void Save(LSL_List lis) 106 public void Save(LSL_List lis)
107 { 107 {
108 if (lis == null) 108 if (lis == null)
109 usage = instance.UpdateHeapUse(usage, 0); 109 usage = instance.UpdateLocalsHeapUse(usage, 0);
110 else 110 else
111 usage = instance.UpdateHeapUse(usage, Size(lis)); 111 usage = instance.UpdateLocalsHeapUse(usage, Size(lis));
112 value = lis; 112 value = lis;
113 } 113 }
114 114
@@ -190,8 +190,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
190 190
191 public void Save(object obj) 191 public void Save(object obj)
192 { 192 {
193 int newuse = Size(obj); 193 usage = instance.UpdateLocalsHeapUse(usage, Size(obj));
194 usage = instance.UpdateHeapUse(usage, newuse);
195 value = obj; 194 value = obj;
196 } 195 }
197 196
@@ -305,8 +304,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
305 304
306 public void Save(string str) 305 public void Save(string str)
307 { 306 {
308 int newuse = Size(str); 307 usage = instance.UpdateLocalsHeapUse(usage, Size(str));
309 usage = instance.UpdateHeapUse(usage, newuse);
310 value = str; 308 value = str;
311 } 309 }
312 310
@@ -318,7 +316,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
318 316
319 public static int Size(string str) 317 public static int Size(string str)
320 { 318 {
321 return (str == null) ? 0 : str.Length * HeapTrackerObject.HT_CHAR; 319 return string.IsNullOrWhiteSpace(str) ? 0 : str.Length * HeapTrackerObject.HT_CHAR;
322 } 320 }
323 } 321 }
324} 322}
diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs
index 32aea25..2fd9b9b 100644
--- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
60 public Delegate[][] iarSDTIntfObjs; 60 public Delegate[][] iarSDTIntfObjs;
61 61
62 private XMRInstAbstract instance; 62 private XMRInstAbstract instance;
63 private int arraysHeapUse; 63 public int arraysHeapUse;
64 64
65 private static readonly XMR_Array[] noArrays = new XMR_Array[0]; 65 private static readonly XMR_Array[] noArrays = new XMR_Array[0];
66 private static readonly char[] noChars = new char[0]; 66 private static readonly char[] noChars = new char[0];
@@ -79,10 +79,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine
79 instance = inst; 79 instance = inst;
80 } 80 }
81 81
82 /*
82 ~XMRInstArrays() 83 ~XMRInstArrays()
83 { 84 {
84 arraysHeapUse = instance.UpdateHeapUse(arraysHeapUse, 0); 85 arraysHeapUse = instance.UpdateArraysHeapUse(arraysHeapUse, 0);
85 } 86 }
87 */
86 88
87 public void Clear() 89 public void Clear()
88 { 90 {
@@ -109,7 +111,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
109 if (iarVectors != null) 111 if (iarVectors != null)
110 newheapUse += iarVectors.Length * HeapTrackerObject.HT_VEC; 112 newheapUse += iarVectors.Length * HeapTrackerObject.HT_VEC;
111 113
112 arraysHeapUse = instance.UpdateHeapUse(0, newheapUse); 114 arraysHeapUse = instance.UpdateArraysHeapUse(0, newheapUse);
113 } 115 }
114 116
115 public void AllocVarArrays(XMRInstArSizes ars) 117 public void AllocVarArrays(XMRInstArSizes ars)
@@ -117,13 +119,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine
117 ClearOldArrays(); 119 ClearOldArrays();
118 int newuse = arraysHeapUse + 120 int newuse = arraysHeapUse +
119 ars.iasChars* HeapTrackerObject.HT_CHAR + 121 ars.iasChars* HeapTrackerObject.HT_CHAR +
120 ars.iasFloats * HeapTrackerObject.HT_SFLT + 122 ars.iasFloats * HeapTrackerObject.HT_DOUB +
121 ars.iasIntegers * HeapTrackerObject.HT_INT + 123 ars.iasIntegers * HeapTrackerObject.HT_INT +
122 ars.iasRotations * HeapTrackerObject.HT_ROT + 124 ars.iasRotations * HeapTrackerObject.HT_ROT +
123 ars.iasVectors * HeapTrackerObject.HT_VEC + 125 ars.iasVectors * HeapTrackerObject.HT_VEC +
124 ars.iasSDTIntfObjs * HeapTrackerObject.HT_DELE; 126 ars.iasSDTIntfObjs * HeapTrackerObject.HT_DELE;
125 127
126 arraysHeapUse = instance.UpdateHeapUse(arraysHeapUse, newuse); 128 arraysHeapUse = instance.UpdateArraysHeapUse(arraysHeapUse, newuse);
127 129
128 iarArrays = (ars.iasArrays > 0) ? new XMR_Array[ars.iasArrays] : noArrays; 130 iarArrays = (ars.iasArrays > 0) ? new XMR_Array[ars.iasArrays] : noArrays;
129 iarChars = (ars.iasChars > 0) ? new char[ars.iasChars] : noChars; 131 iarChars = (ars.iasChars > 0) ? new char[ars.iasChars] : noChars;
@@ -144,7 +146,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
144 public void PopList(int index, LSL_List lis) 146 public void PopList(int index, LSL_List lis)
145 { 147 {
146 int delta = HeapTrackerObject.Size(lis) - HeapTrackerObject.Size(iarLists[index]); 148 int delta = HeapTrackerObject.Size(lis) - HeapTrackerObject.Size(iarLists[index]);
147 instance.UpdateHeapUse(0, delta); 149 instance.UpdateArraysHeapUse(0, delta);
148 Interlocked.Add(ref arraysHeapUse, delta); 150 Interlocked.Add(ref arraysHeapUse, delta);
149 iarLists[index] = lis; 151 iarLists[index] = lis;
150 } 152 }
@@ -155,7 +157,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
155 public void PopObject(int index, object obj) 157 public void PopObject(int index, object obj)
156 { 158 {
157 int delta = HeapTrackerObject.Size(obj) - HeapTrackerObject.Size(iarObjects[index]); 159 int delta = HeapTrackerObject.Size(obj) - HeapTrackerObject.Size(iarObjects[index]);
158 instance.UpdateHeapUse(0, delta); 160 instance.UpdateArraysHeapUse(0, delta);
159 Interlocked.Add(ref arraysHeapUse, delta); 161 Interlocked.Add(ref arraysHeapUse, delta);
160 iarObjects[index] = obj; 162 iarObjects[index] = obj;
161 } 163 }
@@ -166,7 +168,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
166 public void PopString(int index, string str) 168 public void PopString(int index, string str)
167 { 169 {
168 int delta = HeapTrackerString.Size(str) - HeapTrackerString.Size(iarStrings[index]); 170 int delta = HeapTrackerString.Size(str) - HeapTrackerString.Size(iarStrings[index]);
169 instance.UpdateHeapUse(0, delta); 171 instance.UpdateArraysHeapUse(0, delta);
170 Interlocked.Add(ref arraysHeapUse, delta); 172 Interlocked.Add(ref arraysHeapUse, delta);
171 iarStrings[index] = str; 173 iarStrings[index] = str;
172 } 174 }
@@ -233,7 +235,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
233 // others (XMR_Array, XMRSDTypeClObj) keep track of their own heap usage 235 // others (XMR_Array, XMRSDTypeClObj) keep track of their own heap usage
234 236
235 // update script heap usage, throwing an exception before finalizing changes 237 // update script heap usage, throwing an exception before finalizing changes
236 arraysHeapUse = instance.UpdateHeapUse(arraysHeapUse, newheapuse); 238 arraysHeapUse = instance.UpdateArraysHeapUse(arraysHeapUse, newheapuse);
237 239
238 iarChars = chrs; 240 iarChars = chrs;
239 iarFloats = flts; 241 iarFloats = flts;
@@ -258,7 +260,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
258 } 260 }
259 if(iarFloats != null) 261 if(iarFloats != null)
260 { 262 {
261 newheapuse -= iarFloats.Length * HeapTrackerObject.HT_SFLT; 263 newheapuse -= iarFloats.Length * HeapTrackerObject.HT_DOUB;
262 iarFloats = null; 264 iarFloats = null;
263 } 265 }
264 if(iarIntegers != null) 266 if(iarIntegers != null)
@@ -301,7 +303,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
301 iarSDTIntfObjs = null; 303 iarSDTIntfObjs = null;
302 } 304 }
303 305
304 arraysHeapUse = instance.UpdateHeapUse(arraysHeapUse, newheapuse); 306 arraysHeapUse = instance.UpdateArraysHeapUse(arraysHeapUse, newheapuse);
305 } 307 }
306 } 308 }
307 309
@@ -453,35 +455,43 @@ namespace OpenSim.Region.ScriptEngine.Yengine
453 \**************************************************/ 455 \**************************************************/
454 456
455 protected int heapLimit; 457 protected int heapLimit;
456 public int m_heapUsed; 458 public int m_localsHeapUsed;
459 public int m_arraysHeapUsed;
457 460
458 public virtual int UpdateHeapUse(int olduse, int newuse) 461 public virtual int UpdateLocalsHeapUse(int olduse, int newuse)
462 {
463 int newtotal = Interlocked.Add(ref m_localsHeapUsed, newuse - olduse);
464 if (newtotal + glblVars.arraysHeapUse > heapLimit)
465 throw new OutOfHeapException(m_arraysHeapUsed + newtotal + olduse - newuse, newtotal, heapLimit);
466 return newuse;
467 }
468 // not in use
469 public virtual int UpdateArraysHeapUse(int olduse, int newuse)
459 { 470 {
460 if (m_heapUsed < 0) 471 //int newtotal = Interlocked.Add(ref m_arraysheapUsed, newuse - olduse);
461 m_heapUsed = 0; 472 if(newuse + glblVars.arraysHeapUse > heapLimit)
462 int newtotal = Interlocked.Add(ref m_heapUsed, newuse - olduse); 473 throw new OutOfHeapException(m_arraysHeapUsed + newuse + olduse - newuse, newuse, heapLimit);
463 if(newtotal > heapLimit)
464 throw new OutOfHeapException(newtotal + olduse - newuse, newtotal, heapLimit);
465 return newuse; 474 return newuse;
466 } 475 }
467 476
468 public virtual void AddHeapUse(int delta) 477 public virtual void AddLocalsHeapUse(int delta)
478 {
479 Interlocked.Add(ref m_localsHeapUsed, delta);
480 }
481
482 public virtual void AddArraysHeapUse(int delta)
469 { 483 {
470 Interlocked.Add(ref m_heapUsed, delta); 484 Interlocked.Add(ref m_arraysHeapUsed, delta);
471 } 485 }
472 486
473 public int xmrHeapLeft() 487 public int xmrHeapLeft()
474 { 488 {
475 if (m_heapUsed < 0) 489 return heapLimit - m_localsHeapUsed - glblVars.arraysHeapUse;
476 m_heapUsed = 0;
477 return heapLimit - m_heapUsed;
478 } 490 }
479 491
480 public int xmrHeapUsed() 492 public int xmrHeapUsed()
481 { 493 {
482 if(m_heapUsed < 0) 494 return m_localsHeapUsed + glblVars.arraysHeapUse;
483 m_heapUsed = 0;
484 return m_heapUsed;
485 } 495 }
486 496
487 /** 497 /**
diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs
index 3acaef8..6fdb0da 100644
--- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs
@@ -86,7 +86,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
86 m_StackSize = stackSize; 86 m_StackSize = stackSize;
87 m_StackLeft = stackSize; 87 m_StackLeft = stackSize;
88 m_HeapSize = heapSize; 88 m_HeapSize = heapSize;
89 m_heapUsed = 0; 89 m_localsHeapUsed = 0;
90 m_arraysHeapUsed = 0;
90 m_CompilerErrors = errors; 91 m_CompilerErrors = errors;
91 m_StateFileName = GetStateFileName(scriptBasePath, m_ItemID); 92 m_StateFileName = GetStateFileName(scriptBasePath, m_ItemID);
92 93
@@ -904,7 +905,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
904 glblVars.iarStrings = strings; 905 glblVars.iarStrings = strings;
905 glblVars.iarLists = lists; 906 glblVars.iarLists = lists;
906 907
907 AddHeapUse(heapsz); 908 AddArraysHeapUse(heapsz);
908 CheckRunLockInvariants(true); 909 CheckRunLockInvariants(true);
909 } 910 }
910 911
diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs
index 6751cb4..a6d60be 100644
--- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs
@@ -888,7 +888,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
888 m_SleepUntil = DateTime.MinValue; // not doing llSleep() 888 m_SleepUntil = DateTime.MinValue; // not doing llSleep()
889 m_ResetCount++; // has been reset once more 889 m_ResetCount++; // has been reset once more
890 890
891 m_heapUsed = 0; 891 m_localsHeapUsed = 0;
892 m_arraysHeapUsed = 0;
892 glblVars.Clear(); 893 glblVars.Clear();
893 894
894 // Tell next call to 'default state_entry()' to reset all global 895 // Tell next call to 'default state_entry()' to reset all global
diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRSDTypeClObj.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRSDTypeClObj.cs
index 1bdd28e..5db1698 100644
--- a/OpenSim/Region/ScriptEngine/YEngine/XMRSDTypeClObj.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/XMRSDTypeClObj.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
60 public Delegate[][] sdtcITable; 60 public Delegate[][] sdtcITable;
61 61
62 /* 62 /*
63 * These arrays hold the insance variable values. 63 * These arrays hold the instance variable values.
64 * The array lengths are determined by the script compilation, 64 * The array lengths are determined by the script compilation,
65 * and are found in TokenDeclSDTypeClass.instSizes. 65 * and are found in TokenDeclSDTypeClass.instSizes.
66 */ 66 */