You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2021/06/23 07:26:11 UTC
[GitHub] [hadoop] liangxs commented on a change in pull request #3080: HADOOP-17749. Remove lock contention in SelectorPool of SocketIOWithTimeout
liangxs commented on a change in pull request #3080:
URL: https://github.com/apache/hadoop/pull/3080#discussion_r656829433
##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/SocketIOWithTimeout.java
##########
@@ -426,34 +407,44 @@ private synchronized SelectorInfo get(SelectableChannel channel)
*
* @param info
*/
- private synchronized void release(SelectorInfo info) {
+ private static void release(SelectorInfo info) {
long now = Time.now();
trimIdleSelectors(now);
info.lastActivityTime = now;
- info.queue.addLast(info);
+ // SelectorInfos in queue are sorted by lastActivityTime
+ providerMap.get(info.provider).addLast(info);
}
+ private static AtomicBoolean trimming = new AtomicBoolean(false);
+ private static volatile long lastTrimTime = Time.now();
+
/**
* Closes selectors that are idle for IDLE_TIMEOUT (10 sec). It does not
* traverse the whole list, just over the one that have crossed
* the timeout.
*/
- private void trimIdleSelectors(long now) {
+ private static void trimIdleSelectors(long now) {
+ if (!trimming.compareAndSet(false, true)) {
+ return;
+ }
+ if (now - lastTrimTime < IDLE_TIMEOUT / 2) {
Review comment:
@ferhui I remove this check in new commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org