Use FastThreadLocalThread's in shared channel executor.
- 主要言語
- Java
- スター
- 12.1k
- フォーク
- 4k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 37
説明
While working on https://github.com/netty/netty/commit/b88a980482d2aef1163a9abe759f68e685550052 I noticed that when using the blocking stub and the netty transport, we allocate in Netty's allocator from within the shared executor threads. Netty's allocator employs thread local caches that perform the majority of allocations. These caches are accessed via Netty's own threadlocal implementation `FastThreadLocal`, which is only "fast" when used in the context of a `FastThreadLocalThread`.
We should provide our own thread factory to the cached thread pool in order to create `FastThreadLocalThreads`. Additionally, we should override the Thread's `run()` method to do
```
public void run() {
try {
super.run();
} finally {
FastThreadLocal.removeAll();
}
}
```
This will release all memory from a thread's cache when it is shutdown. That should happen quite frequently, with the pool sizing threads dynamically.
However, I don't know how to best implement this. The shared channel executor should be shared by all transport, client, server combinations running in a JVM. Also, I assume we can't rely on the Netty dependency to be there on Android?
コントリビューションガイド
調査の方向性
Start at the shared channel executor and its cached thread pool, then trace how executor threads are created for the Java transport. Implement the requested FastThreadLocalThread creation and cleanup behavior while checking whether the shared executor can remain compatible with Android; done means allocator thread-local caches are released when pool threads shut down.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- backend, performance
- issue の種類
- リファクタリング
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100