Reuse the extracted native library across JVMs to avoid a slow load on macOS
Chưa có ai nhận issue này.
Đá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
- 49/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- java, macos
- Lĩnh vực
- backend, performance
Hướng nghiên cứu
Start by reading NativeLibraryLoader and the native library extraction and loading flow; the issue does not give file paths or test names. Explore how a stable content-derived copy can be safely reused across JVMs and how a fresh copy handles an already-loaded library in the same JVM. Done means repeated JVMs can reuse the extracted library, concurrent extraction remains safe, and the existing fallback still works.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
On macOS, loading Conscrypt's native library costs about 0.6 to 0.9 s in every new JVM, and more on machines with endpoint security software. NativeLibraryLoader copies the library out of the jar into a new temp file with a random name, loads it, and deletes it. macOS checks the code signature of every binary file it has not seen before, so each JVM pays that check in dlopen. Loading a file that has been loaded before takes under 1 ms.
This adds up for test suites and build tools that start many short-lived JVMs. AlexanderGH measured it in Robolectric (robolectric/robolectric#11839): a trivial test takes 3031 ms with Conscrypt loaded the usual way and 2414 ms when Conscrypt loads a previously loaded copy of the same library. A 16 KB dylib shows the same thing:
public class T {
public static void main(String[] a) throws Exception {
java.nio.file.Path p = java.nio.file.Paths.get(a[0]);
if (a.length > 1) { // copy to a new temp file first, as Conscrypt does
java.nio.file.Path t = java.nio.file.Files.createTempFile("tiny", ".dylib");
java.nio.file.Files.copy(p, t, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
p = t;
}
long t0 = System.nanoTime();
System.load(p.toAbsolutePath().toString());
System.out.printf("%s %.1f ms%n", a.length > 1 ? "fresh" : "stable", (System.nanoTime() - t0) / 1e6);
}
}
printf 'int tiny_fn(void){return 42;}\n' > tiny.c && clang -dynamiclib -o libtiny.dylib tiny.c
javac T.java
java T libtiny.dylib fresh # fresh 1335.6 ms
java T libtiny.dylib # stable 0.5 ms
Would you consider extracting the library once, under a name derived from its contents (for example a hash of the resource), into a stable directory, and reusing it when it is already there? Writing it to a temp file and renaming it into place would keep concurrent JVMs safe, and the file would not be deleted after loading. If the stable copy is already loaded by another class loader in the same JVM, falling back to a fresh copy as today would keep that case working. This would also help with #933, since the temp directory would no longer fill up with copies.
The current workaround is to set org.conscrypt.native.workdir to an unwritable directory and put an extracted copy of the library on java.library.path, which relies on Conscrypt's fallback order. Seen with conscrypt-openjdk-uber 2.9.0, JDK 21, macOS 26 on Apple Silicon.
- Ngôn ngữ chính
- Java
- Star
- 1.4k
- Fork
- 332
- Merge trung bình
- 2 ngày 56 phút
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
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 google/conscrypt
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 45/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
Tất cả issue của google/conscrypt
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
new admin: minor issuesĐang mởadmin area
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
alfio-event/alf.io#1556 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
dependency-review: cross-line creation PRs trip the older line's pinned toolchain advisories (issue #30 allow-list, first instance)Có thể đã có người làm @Yash200531 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
HexaHexes/neoforge-mod-template#131 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày