Use FastThreadLocalThread's in shared channel executor.
- Ngôn ngữ chính
- Java
- Star
- 12.1k
- Fork
- 4k
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 37
Mô tả
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?
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu từ channel executor dùng chung và cached thread pool của nó, sau đó theo dõi cách các executor thread được tạo cho Java transport. Triển khai hành vi tạo và dọn dẹp FastThreadLocalThread được yêu cầu, đồng thời kiểm tra xem executor dùng chung có thể tiếp tục tương thích với Android hay không; hoàn tất khi các bộ nhớ đệm thread-local của allocator được giải phóng lúc các pool thread tắt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java
- Lĩnh vực
- backend, performance
- Loại issue
- Tái cấu trúc
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100