[Improvement] Set heartBeatExecutorService as daemon thread#121
Conversation
Codecov Report
@@ Coverage Diff @@
## master #121 +/- ##
============================================
- Coverage 57.17% 57.16% -0.01%
+ Complexity 1201 1200 -1
============================================
Files 150 150
Lines 8177 8178 +1
Branches 773 773
============================================
Hits 4675 4675
Misses 3257 3257
- Partials 245 246 +1
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
|
Why do we need this patch? |
|
I'm not sure whether the main thread of the |
Ok, have you checked similar problems in other code in our project? Could you fix them together? |
|
The same as |
I think we should check all types ExecutorService. A similar pr ba47aa0 |
|
Reference pr you metioned, I set all unnecessary user threads as daemon. |
|
|
||
| protected void sendCommit() { | ||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | ||
| ExecutorService executor = Executors.newSingleThreadExecutor(ThreadUtils.getThreadFactory("bufferManagerSend-%d")); |
There was a problem hiding this comment.
This is a temporary thread pool. I think it's unnecessary to be a daemon thread pool.WDYT?
There was a problem hiding this comment.
Yes, I think I made a mistake here, but I think a better way would have been to generate this executor at this object initialization. @jerqi
There was a problem hiding this comment.
MEMORY_LOCALFILE and MEMROY_HDFS don't call commit operation, so we use a temporary thread pool.
| @VisibleForTesting | ||
| protected void sendCommit() { | ||
| ExecutorService executor = Executors.newSingleThreadExecutor(); | ||
| ExecutorService executor = Executors.newSingleThreadExecutor(ThreadUtils.getThreadFactory("sendCommit-%d")); |
There was a problem hiding this comment.
This is a temporary thread pool. I think it's unnecessary to be a daemon thread pool.WDYT?
There was a problem hiding this comment.
I agree with you here, there really is no need for a daemon thread.
| @Test | ||
| public void testServerMetricsConcurrently() throws Exception { | ||
| ExecutorService executorService = Executors.newFixedThreadPool(3); | ||
| ExecutorService executorService = Executors.newCachedThreadPool( |
There was a problem hiding this comment.
This is a temporary thread pool. I think it's unnecessary to be a daemon thread pool.WDYT?
| CountDownLatch countDownLatch = new CountDownLatch(storageBasePaths.length); | ||
| AtomicInteger successCount = new AtomicInteger(); | ||
| ExecutorService executorService = Executors.newCachedThreadPool(); | ||
| ExecutorService executorService = Executors.newCachedThreadPool( |
There was a problem hiding this comment.
This is a temporary thread pool. I think it's unnecessary to be a daemon thread pool.WDYT?
There was a problem hiding this comment.
Would it be better to create the thread pool when the LocalStorageManager is initialized.
There was a problem hiding this comment.
We only use this thread pool to delete the files once when the server start. I think it's no need.
| private final LocalStorageChecker checker; | ||
| private List<LocalStorage> unCorruptedStorages = Lists.newArrayList(); | ||
| private final Set<String> corruptedStorages = Sets.newConcurrentHashSet(); | ||
| private final ExecutorService executorService = Executors.newCachedThreadPool( |
There was a problem hiding this comment.
We only use this thread pool to delete the files once when the server start. I think it's no need.
There was a problem hiding this comment.
IIRC, a cachedThreadPool should be faster if the number of threads started is known though this is just a test class.
There was a problem hiding this comment.
I'm not sure why these thread numbers are needed here.
There was a problem hiding this comment.
We hope use multi-thread to call some methods, usually thread pool has specific number threads, more tasks is summited, more threads will be created util the thread number reach the max value. I guess that we just ensure multi-thread call the methods, I would like not to modify here.
roryqi
left a comment
There was a problem hiding this comment.
LGTM, thanks @smallzhongfeng

What changes were proposed in this pull request?
When the main thread of the shuffleServer exits, the heartbeat thread should exit as well.
Why are the changes needed?
More formal.
Does this PR introduce any user-facing change?
No
How was this patch tested?
No need.