Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
COMP2121 Lab 1b
Synchrobench Setup with Eclipse
The goal of this lab is to setup the Java version of Synchrobench using the Eclipse IDE.
Exercise 1: Configuring Synchrobench
Open eclipse. Select File > Import... > Git > Projects from Git and click on the Next >
button. Select Clone URI and click on the Next > button.
Figure 1: Cloning the Synchrobench github repository through Eclipse
Select the master branch and click on the Next > button. Specify a location to clone the
git repository, say SB. Select import using New Project wizard, then select Java and
Java Project from Existing Ant Buildfile. Name the project Synchrobench and click
on Browse to retrieve the build file located in SB/java/build.xml.
Choose the appropriate version of Java you want to use:
• if you want Transactional Memory support, select compileJava7;
• if you want the versioned lock linked list that exploits the new Java built-in StampedLock, select
compileJava8.
Duration: 5 min
1
COMP2121 Synchrobench Setup with Eclipse
Figure 2: Selecting Java 7 with TM support or Java 8 with StampedLock support
Exercise 2: Running Benchmarks
Select the Run tab, and click on Run Configurations.... In the Main tab of the opening win-
dow, make sure the Project name is the one of the project you created in the previous question
and enter contention.benchmark.Test as the Main class. In the Arguments window indicate
-b linkedlists.lockbased.LockedLinkedListIntSet -d 3000 -t 8, click Apply and
Run.
You should now observe the linkedlists.lockbased.LockedLinkedListIntSet benchmark
that is a set implemented by a linked list protected by a single global lock, running for 3 seconds with
8 threads after a warmup of 5 seconds. The output should give you the number of operations executed
per second denoted by Throughput (ops/s), as well as the types of executed operations.
Figure 3: Running the linkedlists.lockbased.LockedLinkedListIntSet benchmark dur-
ing 3 seconds with 8 threads
Try other configurations with different benchmarks, with for example:
• Lazy locking synchronization: -b linkedlists.lockbased.LazyListBasedSet
• Hand-over-hand locking synchronization: -b linkedlists.lockbased.LockCouplingListIntSet
Distributed Systems and Network Principles Page 2 of 3
COMP2121 Synchrobench Setup with Eclipse
• Versioned try-lock synchronization: -b linkedlists.lockbased.VersionedListSet
Duration: 10 min
Exercise 3: Transactional Memory Configuration (Java 6/7)
Find your Java runtime library. (Note that you cannot instrument the run-
time library of Java 8, only the ones of Java 6 and 7 are supported) This is
a Java archive usually called rt.jar (sometimes called classes.jar) often lo-
cated in /usr/lib/jvm/java-1.Version-archivecture/jre/lib/ on Linux or
/System/Library/Frameworks/JavaVM.framework/Versions/1.Version/Classes/ on
Mac OS X.
1 find /usr/lib/jvm/ -name rt.jar
Once the PATH to the runtime library is found, instrument the runtime library using the Deuce agent
deuceAgent-1.3.0.jar located in SB/lib/ as follows:
1 > java -jar SB/lib/deuceAgent-1.3.0.jar PATH/rt.jar SB/lib/rt_instrumented.jar
This will create a copy of the runtime java library named rt_instrumented.jar with methods
instrumented (i.e., protected by transactions).
In eclipse, add the deuceAgent-1.3.0.jar and rt_instrumented.jar to
the JRE System Library in your project by right-clicking on it, selecting
Configure Build Path... and Adding External JARs. Go to the ‘Run configura-
tions’ and create a new one, called ‘TM’. In the main tab, make sure the project is the one you
created at the beginning of this session and choose the contention.benchmark.Test as the
main class. In the arguments tab, set the VM arguments as follows (with the absolute path to your
deuceAgent-1.3.0.jar).
1 -Dorg.deuce.exclude="java.util.*,java.lang.*,sun.*"
2 -javaagent:"[ABSOLUTE-PATH-TO-SB]/lib/deuceAgent-1.3.0.jar"
3 -Dorg.deuce.transaction.contextClass=org.deuce.transaction.estmmvcc.Context
In the classpath tab, choose "Add External JARs..." and add the rt_instrumented.jar and place
it above the other user entries.
In the Program arguments of the Arguments tab, select a transactional benchmark like
-b linkedlists.transactional.ElasticLinkedListIntSet -d 3000 -t 8, click
Apply and Run. Try running other transactional benchmarks from linkedlists/transactional,
arrays/transactional, queues/transactional, skiplists/transactional and
trees/transactional.
Duration: 15 min
Distributed Systems and Network Principles Page 3 of 3