Fix write loss on concurrent ivar table growth #479

Closed
wants to merge 19 commits into
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+548 −116
Split
View
@@ -35,7 +35,8 @@
<classpathentry kind="lib" path="build_lib/bcmail-jdk15-146.jar"/>
<classpathentry kind="lib" path="build_lib/bcprov-jdk15-146.jar"/>
<classpathentry kind="lib" path="build_lib/jline-2.7.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="build_lib/ant.jar"/>
+ <classpathentry kind="lib" path="build_lib/unsafe-mock-1.0-SNAPSHOT.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build.eclipse"/>
</classpath>
View
@@ -21,13 +21,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.maven.ide.eclipse.maven2Builder</name>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -188,10 +188,8 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=4
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=insert
@@ -54,13 +54,16 @@ eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_JRuby
formatter_settings_version=12
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n ***** BEGIN LICENSE BLOCK *****\n * Version\: CPL 1.0/GPL 2.0/LGPL 2.1\n *\n * The contents of this file are subject to the Common Public\n * License Version 1.0 (the "License"); you may not use this file\n * except in compliance with the License. You may obtain a copy of\n * the License at http\://www.eclipse.org/legal/cpl-v10.html\n *\n * Software distributed under the License is distributed on an "AS\n * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or\n * implied. See the License for the specific language governing\n * rights and limitations under the License.\n *\n * Alternatively, the contents of this file may be used under the terms of\n * either of the GNU General Public License Version 2 or later (the "GPL"),\n * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),\n * in which case the provisions of the GPL or the LGPL are applicable instead\n * of those above. If you wish to allow use of your version of this file only\n * under the terms of either the GPL or the LGPL, and not to allow others to\n * use your version of this file under the terms of the CPL, indicate your\n * decision by deleting the provisions above and replace them with the notice\n * and other provisions required by the GPL or the LGPL. If you do not delete\n * the provisions above, a recipient may use your version of this file under\n * the terms of any one of the CPL, the GPL or the LGPL.\n ***** END LICENSE BLOCK *****/</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=true
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=false
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
@@ -0,0 +1,79 @@
+require 'benchmark'
+
+
+SIMPLE_TIMES = 10_000_000
+GROWTH_TIMES = 8_000
+
+# prepare dummy objects
+default_object = Class.new.new
+default_object.instance_variable_set(:@foo,2)
+
+disposable_objects = (0..10).map{Class.new.new}
+
+simple_reader = proc do |o|
+ result = nil;
+ for i in (0..SIMPLE_TIMES)
+ result = o.instance_variable_get(:@foo)
+ result = o.instance_variable_get(:@foo)
+ result = o.instance_variable_get(:@foo)
+ result = o.instance_variable_get(:@foo)
+ result = o.instance_variable_get(:@foo)
+ result = o.instance_variable_get(:@foo)
+ result = o.instance_variable_get(:@foo)
+ result = o.instance_variable_get(:@foo)
+ result = o.instance_variable_get(:@foo)
+ result = o.instance_variable_get(:@foo)
+ result = o.instance_variable_get(:@foo)
+ end
+ result
+end
+
+simple_writer = proc do |o|
+ for i in (0..SIMPLE_TIMES)
+ o.instance_variable_set(:@foo,0)
+ o.instance_variable_set(:@foo,1)
+ o.instance_variable_set(:@foo,2)
+ o.instance_variable_set(:@foo,3)
+ o.instance_variable_set(:@foo,4)
+ o.instance_variable_set(:@foo,5)
+ o.instance_variable_set(:@foo,6)
+ o.instance_variable_set(:@foo,7)
+ o.instance_variable_set(:@foo,8)
+ o.instance_variable_set(:@foo,9)
+ end
+end
+
+Benchmark.bmbm do |b|
+ b.report "baseline x#{SIMPLE_TIMES}" do
+ for i in (0..SIMPLE_TIMES)
+ 1
+ end
+ end
+
+ b.report "single threaded reads x#{SIMPLE_TIMES}" do
+ simple_reader.call(default_object)
+ end
+
+ b.report "single threaded writes x#{SIMPLE_TIMES}" do
+ simple_writer.call(default_object)
+ end
+
+ b.report "two reader threads x#{SIMPLE_TIMES}" do
+ t1 = Thread.new{simple_reader.call(default_object)}
+ t2 = Thread.new{simple_reader.call(default_object)}
+ t1.join;t2.join
+ end
+
+ b.report "one reader, one writer x#{SIMPLE_TIMES}" do
+ t1 = Thread.new{simple_reader.call(default_object)}
+ t2 = Thread.new{simple_writer.call(default_object)}
+ t1.join;t2.join
+ end
+
+ b.report "single threaded growth x#{GROWTH_TIMES}" do
+ o = disposable_objects.pop
+ (0..GROWTH_TIMES).each{|i| o.instance_variable_set(:"@bar_#{i}",1)}
+ end
+
+
+end
View
@@ -291,6 +291,7 @@
<compilerarg line="-XDignore.symbol.file=true"/>
<compilerarg line="-J-Dfile.encoding=UTF-8"/>
<compilerarg line="-J-Duser.language=en"/>
+ <compilerarg line="-J-Xbootclasspath/p:build_lib/unsafe-mock-1.0-SNAPSHOT.jar"/>
<compilerarg line="-processor org.jruby.anno.AnnotationBinder"/>
</javac>
Oops, something went wrong.