-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: ThreadWorkerPool支持newVirtualThreadPerTaskExecutor方式使用虚拟线程 #71
base: master
Are you sure you want to change the base?
WIP: ThreadWorkerPool支持newVirtualThreadPerTaskExecutor方式使用虚拟线程 #71
Conversation
All contributors have signed the CLA ✍️ ✅ |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #71 +/- ##
=====================================================
+ Coverage 70.12575% 70.13040% +0.00464%
- Complexity 4211 4241 +30
=====================================================
Files 434 437 +3
Lines 17018 17101 +83
Branches 1726 1728 +2
=====================================================
+ Hits 11934 11993 +59
- Misses 3970 3992 +22
- Partials 1114 1116 +2
|
I have read the CLA Document and I hereby sign the CLA |
trpc-core/src/main/java/com/tencent/trpc/core/management/BaseThreadPoolMXBean.java
Outdated
Show resolved
Hide resolved
trpc-core/src/main/java/com/tencent/trpc/core/management/ThreadPerTaskExecutorWrapper.java
Outdated
Show resolved
Hide resolved
trpc-core/src/main/java/com/tencent/trpc/core/management/BaseThreadPoolMXBean.java
Outdated
Show resolved
Hide resolved
trpc-core/src/test/java/com/tencent/trpc/core/management/ThreadPerTaskExecutorWrapperTest.java
Show resolved
Hide resolved
trpc-core/src/main/java/com/tencent/trpc/core/worker/support/thread/ThreadPoolConfig.java
Outdated
Show resolved
Hide resolved
trpc-core/src/main/java/com/tencent/trpc/core/worker/support/thread/ThreadWorkerPool.java
Outdated
Show resolved
Hide resolved
.getDeclaredMethod(NEW_THREAD_PER_TASK_EXECUTOR_NAME, ThreadFactory.class); | ||
ThreadPerTaskExecutorWrapper wrappedThreadPool = ThreadPerTaskExecutorWrapper | ||
.wrap((ExecutorService) newThreadPerTaskExecutorMethod.invoke(executorsClazz, threadFactory)); | ||
threadPool = wrappedThreadPool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一行看起来多余,threadPool没有地方使用
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个threadPool变量是ThreadWorkPool的属性,是线程池的实例,会有跟维护ThreadWorkPool生命周期相关的操作
trpc-core/src/main/java/com/tencent/trpc/core/worker/support/thread/ThreadPoolConfig.java
Show resolved
Hide resolved
ThreadPerTaskExecutorWrapper wrappedThreadPool = ThreadPerTaskExecutorWrapper | ||
.wrap((ExecutorService) newThreadPerTaskExecutorMethod.invoke(executorsClazz, threadFactory)); | ||
threadPool = wrappedThreadPool; | ||
threadPoolMXBean = new ThreadPerTaskExecutorMXBeanImpl(wrappedThreadPool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L124 - L128缺少单测
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里代码覆盖需要跑在Java21
或者支持fiber的KonaJDK
上
@@ -0,0 +1,30 @@ | |||
package com.tencent.trpc.core.management; | |||
|
|||
import javax.management.MalformedObjectNameException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码很优秀,感谢贡献
用Executors.newVirtualThreadPerTaskExecutor()的方式使用虚拟线程,用ThreadPerTaskExecutor代替,用完立即销毁
使用ExecutorServiceWrapper去实现ThreadPoolMXBean临时使用反射实现,只简单统计了提交和完成的任务数量,近似替代相关数据监控。JEP#444建议使用JFR来监控虚拟线程。