-
Notifications
You must be signed in to change notification settings - Fork 850
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
Added retries to EHOSTUNREACH socket error. #1311
Open
newellz2
wants to merge
2
commits into
NVIDIA:master
Choose a base branch
from
newellz2:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,21 @@ static int envSocketFamily(void) { | |
return family; | ||
} | ||
|
||
/* Set the number of retries for no route to host*/ | ||
static int envNoRouteRetryCount(void) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason to not use the standard NCCL param definition:
Then call |
||
int retries = RETRY_NO_ROUTE_TIMES; | ||
const char* env = ncclGetEnv("NCCL_NO_ROUTE_RETRY_COUNT"); | ||
|
||
if (env == NULL) | ||
return retries; | ||
|
||
retries = atoi(env); | ||
|
||
INFO(NCCL_ENV, "NCCL_NO_ROUTE_RETRY_COUNT set by environment to %s", env); | ||
|
||
return retries; | ||
} | ||
|
||
static int findInterfaces(const char* prefixList, char* names, union ncclSocketAddress *addrs, int sock_family, int maxIfNameSize, int maxIfs) { | ||
#ifdef ENABLE_TRACE | ||
char line[SOCKET_NAME_MAXLEN+1]; | ||
|
@@ -456,6 +471,8 @@ static ncclResult_t socketStartConnect(struct ncclSocket* sock) { | |
/* blocking/non-blocking connect() is determined by asyncFlag. */ | ||
int ret = connect(sock->fd, &sock->addr.sa, sock->salen); | ||
|
||
int noRouteRetriesCount = envNoRouteRetryCount(); | ||
|
||
if (ret == 0) { | ||
sock->state = ncclSocketStateConnected; | ||
return ncclSuccess; | ||
|
@@ -479,6 +496,15 @@ static ncclResult_t socketStartConnect(struct ncclSocket* sock) { | |
} | ||
usleep(SLEEP_INT); | ||
return ncclSuccess; | ||
} else if (errno == EHOSTUNREACH) { | ||
if (++sock->noRouteRetries == noRouteRetriesCount) { | ||
sock->state = ncclSocketStateError; | ||
WARN("socketStartConnect: exceeded no route retries (%d/%d)", sock->noRouteRetries, noRouteRetriesCount); | ||
return ncclRemoteError; | ||
} | ||
INFO(NCCL_ALL, "socketStartConnect: no route retry (%d/%d)", sock->noRouteRetries, noRouteRetriesCount); | ||
usleep(SLEEP_INT); | ||
return ncclSuccess; | ||
} else { | ||
char line[SOCKET_NAME_MAXLEN+1]; | ||
sock->state = ncclSocketStateError; | ||
|
@@ -492,6 +518,8 @@ static ncclResult_t socketPollConnect(struct ncclSocket* sock) { | |
int timeout = 1, ret; | ||
socklen_t rlen = sizeof(int); | ||
|
||
int noRouteRetriesCount = envNoRouteRetryCount(); | ||
|
||
memset(&pfd, 0, sizeof(struct pollfd)); | ||
pfd.fd = sock->fd; | ||
pfd.events = POLLOUT; | ||
|
@@ -529,6 +557,15 @@ static ncclResult_t socketPollConnect(struct ncclSocket* sock) { | |
} | ||
usleep(SLEEP_INT); | ||
sock->state = ncclSocketStateConnecting; | ||
} else if (ret == EHOSTUNREACH) { | ||
if (++sock->noRouteRetries == noRouteRetriesCount) { | ||
sock->state = ncclSocketStateError; | ||
WARN("socketStartConnect: exceeded no route retries (%d/%d)", sock->noRouteRetries, noRouteRetriesCount); | ||
return ncclRemoteError; | ||
} | ||
INFO(NCCL_ALL, "socketStartConnect: no route retry (%d/%d)", sock->noRouteRetries, noRouteRetriesCount); | ||
usleep(SLEEP_INT); | ||
return ncclSuccess; | ||
} else if (ret != EINPROGRESS) { | ||
sock->state = ncclSocketStateError; | ||
char line[SOCKET_NAME_MAXLEN+1]; | ||
|
@@ -700,6 +737,7 @@ ncclResult_t ncclSocketInit(struct ncclSocket* sock, union ncclSocketAddress* ad | |
if (sock == NULL) goto exit; | ||
sock->timedOutRetries = 0; | ||
sock->refusedRetries = 0; | ||
sock->noRouteRetries = 0; | ||
sock->abortFlag = abortFlag; | ||
sock->asyncFlag = asyncFlag; | ||
sock->state = ncclSocketStateInitialized; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think it is better to have configurable
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.
I agree. Maybe something similar to NCCL_IB_RETRY_CNT? What do you think about making RETRY_REFUSED_TIMES and RETRY_TIMEDOUT_TIMES also configurable via environmental variables?