当前位置:网站首页>Biased lock, lightweight lock test tool class level related commands
Biased lock, lightweight lock test tool class level related commands
2022-07-29 06:47:00 【The evil way does not miss the firewood cutting skill】
Dependency package
Recommended for dependent packages 0.9 Version of , Other versions may have different effects , Treasure .
<dependency>
<groupId>org.openjdk.jol</groupId>
<artifactId>jol-core</artifactId>
<version>0.9</version>
</dependency>
Demo code
package com.xxl.job.admin.mytest;
import org.openjdk.jol.info.ClassLayout;
import java.util.concurrent.TimeUnit;
public class ObjectMarkWordDemo {
public void test() {
Object obj = new Object();
synchronized (obj) {
System.out.println("111");
}
synchronized (obj) {
System.out.println("111");
}
synchronized (obj) {
System.out.println("111");
}
}
public static void main(String[] args) throws InterruptedException {
// Print JVM Relevant information
// System.out.println(VM.current().details());
// Print whether each object is 8 Integer multiple size of
// System.out.println(VM.current().objectAlignment());
MyObject myObject = new MyObject();
System.out.println(Integer.toHexString(myObject.hashCode()));
new Thread(()->{
// stay myObject Lock the object head ( By default, it works directly to the lightweight lock , Here I have to put him in a locked state )
// The default is to open the bias lock , So here we only need to modify the delay time of opening the bias lock to 0 Easy to see -XX:+BiasedLockingStartupDelay=0
synchronized (myObject) {
// Lock this thread , And also set the bias thread ID
System.out.println(ClassLayout.parseInstance(myObject).toPrintable());
}
}).start();
TimeUnit.MICROSECONDS.sleep(500);
// The lock was released , So what is printed here must be unlocked 001
System.out.println(ClassLayout.parseInstance(myObject).toPrintable());
}
}
class MyObject {
}
Running results :
76fb509a
# WARNING: Unable to attach Serviceability Agent. You can try again with escalated privileges. Two options: a) use -Djol.tryWithSudo=true to try with sudo; b) echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
com.xxl.job.admin.mytest.MyObject object internals:
OFFSET SIZE TYPE DESCRIPTION VALUE
0 4 (object header) e8 29 c3 0a (11101000 00101001 11000011 00001010) (180562408)
4 4 (object header) 03 00 00 00 (00000011 00000000 00000000 00000000) (3)
8 4 (object header) 44 c1 00 f8 (01000100 11000001 00000000 11111000) (-134168252)
12 4 (loss due to the next object alignment)
Instance size: 16 bytes
Space losses: 0 bytes internal + 4 bytes external = 4 bytes total
# WARNING: Unable to attach Serviceability Agent. You can try again with escalated privileges. Two options: a) use -Djol.tryWithSudo=true to try with sudo; b) echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
com.xxl.job.admin.mytest.MyObject object internals:
OFFSET SIZE TYPE DESCRIPTION VALUE
0 4 (object header) e8 29 c3 0a (11101000 00101001 11000011 00001010) (180562408)
4 4 (object header) 03 00 00 00 (00000011 00000000 00000000 00000000) (3)
8 4 (object header) 44 c1 00 f8 (01000100 11000001 00000000 11111000) (-134168252)
12 4 (loss due to the next object alignment)
Instance size: 16 bytes
Space losses: 0 bytes internal + 4 bytes external = 4 bytes total
Common commands
Set up JVM Heap size
-Xms10m -Xmx10m
Inquire about JVM Start and run those commands
java -XX:+PrintCommandLineFlags -version
Close the compression configuration of class pointer in the object header
-XX:-UseCompressedClassPointers
Check whether the deflection lock is turned on
java -XX:+PrintFlagsInitial | grep BiasedLock
Running results :
intx BiasedLockingBulkRebiasThreshold = 20 {
product}
intx BiasedLockingBulkRevokeThreshold = 40 {
product}
intx BiasedLockingDecayTime = 25000 {
product}
// After the deflection lock is opened, there will be 4s The delay of the clock , When testing, you need to pay attention to , You can set this value to 0, Easy to view
intx BiasedLockingStartupDelay = 4000 {
product}
bool TraceBiasedLocking = false {
product}
// JVM The setting of deflection lock is enabled by default
bool UseBiasedLocking = true {
product}
Turn on the deflection lock setting
-XX:+UseBiasedLocking -XX:BiasedLockingStartupDelay=0
边栏推荐
- 5、 Wireless communication network
- ss命令详解
- 多线程并发下的指令重排问题
- Hongke share | let you have a comprehensive understanding of "can bus errors" (IV) -- producing and recording can errors in practice
- 非常实用的 Shell 和 shellcheck
- ping 原理
- Hongke share | bring you a comprehensive understanding of "can bus error" (I) -- can bus error and error frame
- What is DNS amplification attack
- day03_2_作业
- Hongke share | FPGA implementation of pass through and store and forward switching delay
猜你喜欢

软件定义边界SDP

day10_ Exception handling & enumeration

apisix健康检查测试

centos 部署postgresql 13

Hongke share | FPGA implementation of pass through and store and forward switching delay

Hongke shares | why EtherCAT is the best solution to improve the performance of the control system?

Relationship between subnet number, host number and subnet mask

Hongke case | PAC: an integrated control solution integrating SoftPLC control logic, HMI and other service functions

Complex floating point multiplication of vivado IP core floating point

day03_ 1_ Process control
随机推荐
CNN-卷积神经网络
Is it OK to directly compare the size of two numbers in FPGA?
解决文件大导致磁盘满的问题
day03_2_作业
循环神经网络RNN
Thinking about MySQL taking shell through OS shell
网站受DDoS攻击的表现以及查看方法
有用网站
软件定义边界SDP
centos 部署postgresql 13
apisix健康检查测试
Traffic characteristics of webshell management tools
Instant 新日期类的使用 API
JMM 内存模型概念
day15_ generic paradigm
Hongke automation SoftPLC | Hongke kPa modk operation environment and construction steps (2) -- modk operation environment construction
Six common ways for hackers to attack servers
C语言数据类型
为什么5G N2接口控制面使用SCTP协议?
Enterprise manager cannot connect to the database instance in Oracle10g solution