[Mono-bugs] [Bug 80391][Nor] New - Calling generic methods on interfaces is very slow
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Thu Dec 28 21:57:25 EST 2006
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by rolfkvinge at ya.com.
http://bugzilla.ximian.com/show_bug.cgi?id=80391
--- shadow/80391 2006-12-28 21:57:25.000000000 -0500
+++ shadow/80391.tmp.10743 2006-12-28 21:57:25.000000000 -0500
@@ -0,0 +1,89 @@
+Bug#: 80391
+Product: Mono: Runtime
+Version: 1.0
+OS: other
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: JIT
+AssignedTo: lupus at ximian.com
+ReportedBy: rolfkvinge at ya.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Calling generic methods on interfaces is very slow
+
+Calling generic methods on interfaces is very slow, code to reproduce:
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Text;
+
+class vbnc_bugs {
+ interface iface {
+ void method<T> ();
+ }
+ class test : iface {
+ public void method<T> () { }
+ }
+ static void Main (string [] args)
+ {
+ int iterations = 100000;
+ DateTime start;
+ TimeSpan t1, t2;
+ test tester = new test ();
+ iface itester = tester;
+
+ if (args.Length == 1)
+ iterations = int.Parse (args [0]);
+
+ start = DateTime.Now;
+ for (int i = 0; i < iterations; i++) {
+ itester.method <object> ();
+ }
+ t1 = DateTime.Now - start;
+
+ start = DateTime.Now;
+ for (int i = 0; i < iterations; i++) {
+ tester.method <object> ();
+ }
+ t2 = DateTime.Now - start;
+
+ Console.WriteLine ("{0} iterations, with generics {1} ms,
+without {2} ms", iterations, (int) t1.TotalMilliseconds, (int)
+t2.TotalMilliseconds);
+ }
+}
+
+Some benchmarks:
+MS:
+1000 iterations, with generics 0 ms, without 0 ms
+10000 iterations, with generics 0 ms, without 0 ms
+100000 iterations, with generics 0 ms, without 0 ms
+1000000 iterations, with generics 15 ms, without 15 ms
+10000000 iterations, with generics 250 ms, without 62 ms
+100000000 iterations, with generics 2765 ms, without 828 ms
+
+1000 iterations, with generics 24 ms, without 0 ms
+10000 iterations, with generics 177 ms, without 0 ms
+100000 iterations, with generics 4687 ms, without 0 ms
+1000000 iterations, c-c'ed after a long wait.
+
+If I debug with gdb and c-c, I'll almost always get this stack trace:
+#0 0xb7e1518d in memmove () from /lib/libc.so.6
+#1 0xb7f178a9 in g_array_insert_vals () from /opt/gnome/lib/libglib-
+2.0.so.0
+#2 0x08097dde in mono_jit_info_table_add (domain=0x21ed8, ji=0x8eca5b4)
+at domain.c:220
+#3 0x08155f3c in mini_method_compile (method=0x8ed4cf8, opts=5335551,
+domain=0x21ed8, run_cctors=<value optimized out>, compile_aot=<value
+optimized out>, parts=0) at mini.c:10461
+#4 0x08156651 in mono_jit_compile_method (method=0x8ed4cf8) at
+mini.c:10559
+#5 0x08157231 in mono_helper_compile_generic_method (obj=0x2ffe8,
+method=0x826b918, context=0x826b8e8, this_arg=0xbfbbc20c) at jit-
+icalls.c:804
More information about the mono-bugs
mailing list