[Mono-bugs] [Bug 58027][Wis] New - get rid of synch block in MonoObject

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 4 May 2004 15:12:04 -0400 (EDT)


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 vargaz@freemail.hu.

http://bugzilla.ximian.com/show_bug.cgi?id=58027

--- shadow/58027	2004-05-04 15:12:04.000000000 -0400
+++ shadow/58027.tmp.24290	2004-05-04 15:12:04.000000000 -0400
@@ -0,0 +1,37 @@
+Bug#: 58027
+Product: Mono: Runtime
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: vargaz@freemail.hu               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: get rid of synch block in MonoObject
+
+Currently, MonoObject contains a 4 byte sync block used for implementing
+synchronization. Most of the time, this field is unused since most objects
+are never locked. For example, mcs creates about 3000000 objects during a
+corlib compilation. This means that 12 mb memory is used for just the sync
+blocks. This is about 10% of the total memory usage of mcs. Besides taking
+up space, they hurt cache behavior, slow down garbage collections etc. So
+they should not be in every object.
+
+Some alternatives:
+- allocate sync blocks out-of-line in some kind of data structure. This
+  solution is good memory-wise, but the data structure needs to be locked,
+  searched etc. so it slows down locking greatly.
+- put the sync block only into objects of specific types. Candidates
+  include Object (since the Net framework recommends using a newly
+   allocated Object for synchronization), and Type (since 
+   static synchronized objects synchronize on the type). If an object
+  which does not have a sync block needs to be synchronized, it is done
+  using alternative (1). Types needing a sync block could also be 
+  annotated with a custom attribute, like Mono.SynchronizationAttribute.