Java Concurrent Stress Test

The Java Concurrency Stress tests (jcstress) is an experimental harness and a suite of tests to aid the research in the correctness of concurrency support in the JVM, class libraries, and hardware.

All source code is available at github.

How to run jstress test

  • Create jcstress maven project
[yunpxu@yunpxu-mac IdeaProjects]$ mvn archetype:generate \
  -DinteractiveMode=false \
  -DarchetypeGroupId=org.openjdk.jcstress \
  -DarchetypeArtifactId=jcstress-java-test-archetype \
  -DarchetypeVersion=0.5 \
  -DgroupId=com.jcst \
  -DartifactId=jcst \
  -Dversion=1.0
  • Import jcstress-samples
<dependency>
    <groupId>org.openjdk.jcstress</groupId>
    <artifactId>jcstress-samples</artifactId>
    <version>${jcstress.version}</version>
</dependency>
  • Clean Package
[yunpxu@yunpxu-mac IdeaProjects]$ cd jcst/
[yunpxu@yunpxu-mac jcst]$ mvn clean package
  • Jstress help
java -jar target/jcstress.jar -h
  • List jstress test with full class name match APISample
java -jar target/jcstress.jar -t APISample -l
  • Run jstress test with full class name match ConcurrencyTest
[yunpxu@yunpxu-mac jcst]$ java -jar target/jcstress.jar -t ConcurrencyTest
  • Run all jstress tests
[yunpxu@yunpxu-mac jcst]$ java -jar target/jcstress.jar
  • Check jcst results
[yunpxu@yunpxu-mac jcst]$ tree
.
├── jcst.iml
├── jcstress-results-2019-03-19-17-31-42.bin.gz
├── pom.xml
├── results
     ├── com.jcst.ConcurrencyTest.html
     └── index.html

Concepts

  • JCStressTest
    Mark the class as JCStress test.
  • Description
    @Description("Sample Hello World test")
  • Ref
    @Ref("http://openjdk.java.net/projects/code-tools/jcstress/")
  • JCStressMeta
    @JCStressMeta(APISample_05_SharedMetadata.class)
    Inherit Description, Outcome and Ref etc.. from the pointed class
  • Mode.Continuous
    Run multiple Actor/Arbiter threads
  • Mode.Termination
    Run a single Actor thread
  • Outcome
    Describes the test outcome, and how to deal with it.
    @Outcome(id = "1, 1", expect = Expect.ACCEPTABLE, desc = "")
    @Outcome(id = "1, 2", expect = Expect.ACCEPTABLE_INTERESTING, desc = "")
    @Outcome(id = "2, 1", expect = Expect.FORBIDDEN, desc = "")
  • State
    It annotates the class that holds the data mutated/read by the tests.
  • Actor
    Actor method is executed by multiple threads.
  • Arbiter
    Arbiter method is executed after Actor, memory effects from Actor are visible to Arbiter.
  • Signal
    Signal method deliver a termination signal to a running Actor.

JCST Samples

You can check the sample source code from here.
You can run all the jcst samples with java -jar target/jcstress.jar, this may take about 30mins.

Environment and Test Configurations.png

API Sample

API Sample.png

Operation Atomicity

Concurrency Sample Operation Atomicity.png

ConcurrentHashMap

Concurrency Sample ConcurrentHashMap.png

JMM NatureAccessAtomicity

JMM Nature Access Atomicity.png

JMM UnNatureAccessAtomicity

JMM UnNature Access Atomicity.png

JMM Sample Word Tearing

Word Tearing.png

JMM Sample Coherence

Coherence.png

JMM Sample Partial Order

Partial Order.png

JMM Sample Total Order

Total Order.png

JMM Sample Finals

Finals.png

Reference

OpenJDK jcstress wiki

Jcstress samples

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末鹰祸,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌木西,老刑警劉巖蚪腋,帶你破解...
    沈念sama閱讀 221,888評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件胀莹,死亡現(xiàn)場離奇詭異,居然都是意外死亡蒲障,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,677評論 3 399
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來晌涕,“玉大人滋捶,你說我怎么就攤上這事∮嗬瑁” “怎么了重窟?”我有些...
    開封第一講書人閱讀 168,386評論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長惧财。 經(jīng)常有香客問我巡扇,道長,這世上最難降的妖魔是什么垮衷? 我笑而不...
    開封第一講書人閱讀 59,726評論 1 297
  • 正文 為了忘掉前任厅翔,我火速辦了婚禮,結(jié)果婚禮上搀突,老公的妹妹穿的比我還像新娘刀闷。我一直安慰自己,他們只是感情好仰迁,可當(dāng)我...
    茶點故事閱讀 68,729評論 6 397
  • 文/花漫 我一把揭開白布甸昏。 她就那樣靜靜地躺著,像睡著了一般徐许。 火紅的嫁衣襯著肌膚如雪施蜜。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,337評論 1 310
  • 那天雌隅,我揣著相機與錄音翻默,去河邊找鬼。 笑死恰起,一個胖子當(dāng)著我的面吹牛修械,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播村缸,決...
    沈念sama閱讀 40,902評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼祠肥,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了梯皿?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,807評論 0 276
  • 序言:老撾萬榮一對情侶失蹤县恕,失蹤者是張志新(化名)和其女友劉穎东羹,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體忠烛,經(jīng)...
    沈念sama閱讀 46,349評論 1 318
  • 正文 獨居荒郊野嶺守林人離奇死亡属提,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,439評論 3 340
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片冤议。...
    茶點故事閱讀 40,567評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡斟薇,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出恕酸,到底是詐尸還是另有隱情堪滨,我是刑警寧澤,帶...
    沈念sama閱讀 36,242評論 5 350
  • 正文 年R本政府宣布蕊温,位于F島的核電站袱箱,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏义矛。R本人自食惡果不足惜发笔,卻給世界環(huán)境...
    茶點故事閱讀 41,933評論 3 334
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望凉翻。 院中可真熱鬧了讨,春花似錦、人聲如沸制轰。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,420評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽艇挨。三九已至残炮,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間缩滨,已是汗流浹背势就。 一陣腳步聲響...
    開封第一講書人閱讀 33,531評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留脉漏,地道東北人苞冯。 一個月前我還...
    沈念sama閱讀 48,995評論 3 377
  • 正文 我出身青樓,卻偏偏與公主長得像侧巨,于是被迫代替她去往敵國和親舅锄。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,585評論 2 359

推薦閱讀更多精彩內(nèi)容