Reuse the extracted native library across JVMs to avoid a slow load on macOS
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 49/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- java, macos
- 領域
- backend, performance
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Java
- スター
- 1.4k
- フォーク
- 332
- 平均マージ
- 2日 56分
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google/conscrypt のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 3/5 半日 初心者へのやさしさ 45/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
google/conscrypt の issue をすべて見る
似ている issue
-
beginner difficulty: easy documentation good first issue hacktoberfest help wanted observability size/S up-for-grabs
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
dmitriy-iliyov/spring-transactional-outbox#82 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
RamazanKara/nightjar#264 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
netty/netty#18628 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
apache/flink-agents#1500 ·
メンテナーはふだん 1 日以内に返信
-
bug frontend
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
sylvainmetayer/planning-equipes#495 ·
メンテナーはふだん 1 日以内に返信