Very heavy lock contention under load
@brettwooldridge đang làm issue này rồi.
Từ ngày 26/9/2025.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 28/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- java
- Lĩnh vực
- backend, performance
Hướng nghiên cứu
Bắt đầu trong src/com/sun/jna/internal/Cleaner.java tại Cleaner.register, sau đó lần theo các caller được hiển thị trong stack trace, đặc biệt là việc khởi tạo Memory và ByReference. Tái hiện lỗi khi khởi động lạnh với khoảng 1.000 thread trên Linux amd64 và xác nhận rằng tình trạng tranh chấp lock được giảm hoặc loại bỏ dưới tải tương đương.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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)
- Ngôn ngữ chính
- Java
- Star
- 8.9k
- Fork
- 1.7k
- Merge trung bình
- 1 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của java-native-access/jna
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 48/100
java-native-access/jna#1742 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 66/100
java-native-access/jna#1738 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
java-native-access/jna#1736 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
java-native-access/jna#1717 ·
-
Windows32Exception - The parameter is incorrectCó thể đã có người làm @marktech0813 đã nhận 335 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
java-native-access/jna#1700 · 11 bình luận ·
Tất cả issue của java-native-access/jna
Issue tương tự
-
[BUG] Re-subscribing the Mono returned by listTools/listResources/listResourceTemplates/listPrompts/listRoots duplicates the resultsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
modelcontextprotocol/java-sdk#1174 · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
module: core
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
bigbluebutton/bigbluebutton#26028 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Fix SNMP4J Agent vulnerabilityĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
MetricsHub/metricshub-community#1390 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
apache/rocketmq-dashboard#6331 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Upgrade to Commons Codec 1.23.0Đang mởstatus: team-only type: dependency-upgrade
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
spring-projects/spring-boot#52143 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày