Very heavy lock contention under load
还没有人认领这个 Issue。
- #1684 来自 @brettwooldridge —— 已关闭,未合并
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 28/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- java
- 领域
- backend, performance
调研方向
从 src/com/sun/jna/internal/Cleaner.java 中的 Cleaner.register 开始,然后跟踪 stack trace 中显示的调用方,尤其是 Memory 和 ByReference 的构造。在 Linux amd64 上以大约 1,000 个线程进行冷启动复现,并确认在相当的负载下 lock 竞争有所减少或消除。
由索引模型根据 Issue 内容生成。
描述
We're experiencing very heavy lock contention with version 5.14. It's in this section of the code https://github.com/java-native-access/jna/blob/5.14.0/src/com/sun/jna/internal/Cleaner.java#L58. In one of the thread dumps we see 647 threads waiting on the lock. We were initially running 5.10, upgrading to 5.14 didn't help.
We've tried with the latest Zulu JDK 22 and JDK 21, same result. Linux amd64. This problem now always triggers in our app immediately after a fresh start, possibly because the JVM is slower. If reduce the amount of threads initially then it doesn't trigger immediately, but it still happens after a while. Sometimes stopping and restarting the threads helps.
The server is not overloaded. We increased the number of cores two-fold and we're still experiencing the problem.
Below is the relevant part of the stacktrace.
Not sure how you can reproduce, in our case we always see this problem from cold start with about 1000 threads.
Any thoughts?
"pool-4-thread-447" #4038 [3373050] prio=5 os_prio=0 cpu=2546.58ms elapsed=612.63s tid=0x00007f5e28011e90 nid=3373050 runnabl
java.lang.Thread.State: RUNNABLE
at com.sun.jna.internal.Cleaner.register(Cleaner.java:58)
- locked <0x00007f6069fdc500> (a com.sun.jna.internal.Cleaner)
at com.sun.jna.Memory.<init>(Memory.java:122)
at com.sun.jna.ptr.ByReference.<init>(ByReference.java:57)
at com.sun.jna.ptr.IntByReference.<init>(IntByReference.java:35)
at com.sun.jna.ptr.IntByReference.<init>(IntByReference.java:31)
at java.lang.invoke.LambdaForm$DMH/0x00007f5fbbf19800.newInvokeSpecial([email protected]/LambdaForm$DMH)
at java.lang.invoke.Invokers$Holder.invokeExact_MT([email protected]/Invokers$Holder)
at jdk.internal.reflect.DirectConstructorHandleAccessor.invokeImpl([email protected]/DirectConstructorHandleAccessor.j
at jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance([email protected]/DirectConstructorHandleAccessor.
at java.lang.reflect.Constructor.newInstanceWithCaller([email protected]/Constructor.java:502)
at java.lang.reflect.Constructor.newInstance([email protected]/Constructor.java:486)
at com.sun.jna.Klass.newInstance(Klass.java:48)
at com.sun.jna.NativeMappedConverter.defaultValue(NativeMappedConverter.java:65)
at com.sun.jna.Structure.initializeField(Structure.java:1440)
at com.sun.jna.Structure.initializeFields(Structure.java:1416)
at com.sun.jna.Structure.<init>(Structure.java:218)
at com.sun.jna.Structure.<init>(Structure.java:204)
at com.sun.jna.Structure.<init>(Structure.java:191)
at com.sun.jna.Structure.<init>(Structure.java:183)
- 主要语言
- Java
- 星标
- 8.9k
- 派生
- 1.7k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
java-native-access/jna 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
java-native-access/jna#1740 ·
-
难度 4/5 3-5 天 新手友好度 66/100
java-native-access/jna#1738 ·
-
难度 4/5 3-5 天 新手友好度 45/100
java-native-access/jna#1736 ·
-
难度 3/5 1-2 天 新手友好度 65/100
java-native-access/jna#1717 ·
-
Windows32Exception - The parameter is incorrect可能重新可做 @marktech0813 于 331 天前认领,目前没有进行中的 PR。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
java-native-access/jna#1700 · 11 条评论 ·
查看 java-native-access/jna 的全部 Issue
相似的 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
waiting-for-triage
难度 1/5 1 小时以内 新手友好度 72/100
spring-cloud/spring-cloud-openfeign#1443 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 84/100
ADORSYS-GIS/keycloak-oid4vp-plugin#221 ·
维护者通常 2 天内回复
-
status: team-only type: dependency-upgrade
难度 2/5 1-3 小时 新手友好度 65/100
spring-projects/spring-boot#52099 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
tchiotludo/akhq#3307 · 1 个 reaction ·
维护者通常 1 天内回复