Bug 314838 (MONO59006) - [PATCH] [perf] stelem.ref perf
Summary: [PATCH] [perf] stelem.ref perf
Status: RESOLVED FIXED
Alias: MONO59006
Product: Mono: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-25 06:51 UTC by Ben Maurer
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
a faster version (8.75 KB, patch)
2004-06-30 03:01 UTC, Thomas Wiest
Details | Diff
new version (9.74 KB, patch)
2004-07-12 19:07 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 18:39:14 UTC


---- Reported by bmaurer@users.sf.net 2004-05-24 23:51:46 MST ----

Our performance on the following test case is 7x worse than MS.NET

using System;

class T {
	static void Main () {
		object [] o = new object [50];
		object oo = new object ();
		A (o, oo);
		
	}
	
	static void A (object [] o, object oo) {
		if (oo == null)
			A (o, oo);
		for (int i = 0; i < 5000000; i ++)
			o [1] = oo;
	}
}

Also, when I removed the stelem.ref array type msismatch check, MCS
bootstrap time improved by 6%.

Part of the issue is the managed -> unmanaged transition. However, the
other part is that the typecheck itself seems to be slow. When I skipped
the LMF stuff, I was only 2x slower.



---- Additional Comments From bmaurer@users.sf.net 2004-06-29 20:01:23 MST ----

Created an attachment (id=166094)
a faster version




---- Additional Comments From bmaurer@users.sf.net 2004-06-29 20:02:42 MST ----

This patch implements a fast case for the stelem.ref opcode in managed
code. If the quick test fails, the code falls back on to managed code.

This gave me a nice 3% boost in MCS.

I was able to do a full bootstrap with this patch. I also added some
regression tests (in the patch) which passed.



---- Additional Comments From vargaz@freemail.hu 2004-07-08 15:20:27 MST ----

This looks good, some notes:
- instead of 

mono_mb_emit_managed_call (mb,
+		mono_marshal_get_icall_wrapper (isinst_sig, "mono_object_isinst",
mono_object_isinst),
+		NULL);

, you should register mono_object_isinst as a JIT icall in
mono_marshal_init and call it using mono_mb_emit_icall like this:

		register_icall (mono_object_isinst, "mono_object_isinst", "object
object ptr", FALSE);

- the wrapper should have a new wrapper type instead of UNKNOWN. This
  is important since it enables the AOT code to distinguish between 
wrappers.

- maybe call the C function and the generated method 'stelem_ref' to
  comply with the naming convention in other parts of the code.

- You might want to experiment with inlining the method into its 
caller like it is done with CEE_ISINST.






---- Additional Comments From bmaurer@users.sf.net 2004-07-12 12:07:47 MST ----

Created an attachment (id=166095)
new version




---- Additional Comments From bmaurer@users.sf.net 2004-07-12 12:08:16 MST ----

This version addresses all of zoltan's comments except for the
inlining one (will consider that more later).




---- Additional Comments From vargaz@freemail.hu 2004-07-14 13:10:13 MST ----

This looks good, so feel free to check it in. The 'sig' variable is
no longer needed in the new version.



---- Additional Comments From bmaurer@users.sf.net 2004-07-16 11:22:02 MST ----

Done

Imported an attachment (id=166094)
Imported an attachment (id=166095)

Unknown operating system unknown. Setting to default OS "Other".