[sgen-gray-queue] Add graystack stress test
authorLudovic Henry <ludovic.henry@xamarin.com>
Fri, 13 Jun 2014 23:26:18 +0000 (19:26 -0400)
committerLudovic Henry <ludovic.henry@xamarin.com>
Thu, 26 Jun 2014 00:08:52 +0000 (17:08 -0700)
mono/tests/Makefile.am
mono/tests/gc-graystack-stress.cs [new file with mode: 0644]
mono/tests/stress-runner.pl

index a358ecd27ff2f75f2184402c83b5cafc5658639f..5a634b7e2658cd699b35675be82bb1f6f9271021 100644 (file)
@@ -43,6 +43,7 @@ STRESS_TESTS_SRC=     \
        monitor-stress.cs       \
        thread-stress.cs        \
        gc-stress.cs            \
+       gc-graystack-stress.cs          \
        exit-stress.cs          \
        process-stress.cs       \
        assembly-load-stress.cs
@@ -927,6 +928,7 @@ SGEN_TESTS =        \
        sgen-cementing-stress.exe       \
        sgen-case-23400.exe     \
        sgen-new-threads-dont-join-stw.exe      \
+       gc-graystack-stress.exe \
        bug-17590.exe
 
 SGEN_CONFIGURATIONS =  \
diff --git a/mono/tests/gc-graystack-stress.cs b/mono/tests/gc-graystack-stress.cs
new file mode 100644 (file)
index 0000000..7d711d9
--- /dev/null
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+
+class Program {
+       
+       class Node {
+               Node child;
+               Node sibling;
+
+               public Node (int depth) : this (depth, null) {}
+
+               public Node (int depth, Node sibling) {
+                       if (depth > 0)
+                               this.child = new Node (depth - 1);
+
+                       this.sibling = sibling;
+               }
+
+               public override String ToString () {
+                       return String.Format ("Node[child={0},sibling={1}]", this.child, this.sibling);
+               }
+       }
+       
+       /**
+        * Usage : width [depth [collections]]
+        *  - width : trigger the overflow
+        *  - depth : modify the cost difference of the overflow
+        *  - collections : # of collections to perform
+        */
+       public static void Main (String[] args) {
+               int width = 125;
+               if (args.Length > 0)
+                       width = Math.Max (width, Int32.Parse (args [0]));
+
+               int depth = 10000;
+               if (args.Length > 1)
+                       depth = Math.Max (depth, Int32.Parse (args [1]));
+
+               int collections = 100;
+               if (args.Length > 2)
+                       collections = Math.Max (collections, Int32.Parse (args [2]));
+
+               Node sibling = null;
+
+               for (int i = 0; i < width; i++) {
+                       sibling = new Node(depth, sibling);
+                       if (i > 0 && i % 10 == 0)
+                               Console.Write ("+");
+               }
+
+               for (int i = 0; i < collections; i++) {
+                       GC.Collect();
+                       if (i > 0 && i % 10 == 0)
+                               Console.Write (".");
+               }
+               Console.WriteLine ();
+       }
+}
index 0e193c307ea9148a88efdaae00946e09fe3f484a..24d5b9db8d5e0f9f2962c77fae10992af87900e7 100755 (executable)
@@ -65,6 +65,13 @@ my %tests = (
                'arg-knob' => 0, # loops
                'ratio' => 20,
        },
+       'gc-graystack-stress' => {
+               'program' => 'gc-graystack-stress.exe',
+               # width, depth, collections
+               'args' => [125, 10000, 100],
+               'arg-knob' => 2, # loops
+               'ratio' => 10,
+       },
        'thread-stress' => {
                'program' => 'thread-stress.exe',
                # loops