Adding robustness to the hostname indexing#466
Merged
TApplencourt merged 3 commits intodevelfrom Feb 16, 2026
Merged
Conversation
xprof/xprof.rb.in
Outdated
| @@ -255,7 +255,13 @@ module MPITopo | |||
| # (e.g. x4117c4s4b0n0.hsn.cm.aurora.alcf.anl.gov) and the Socket.gethostname is just x4117c4s4b0n0 | |||
| hostnames = File.readlines(hostfile).map { |el| el.split('.', 2).first } | |||
Collaborator
There was a problem hiding this comment.
I suppose we can remove the split and stuff now :)
Contributor
Author
There was a problem hiding this comment.
good idea! pushed!
| hostnames = File.readlines(hostfile) | ||
| # find index of hostname_string in list_hostnames | ||
| hostname_id = hostnames.find_index(Socket.gethostname) | ||
| hostname_id = hostnames.find_index{ |host| host.start_with?(Socket.gethostname) } |
Collaborator
There was a problem hiding this comment.
so we can do it in online now :D
File.readlines(hostfile).find_index{ |hostname| hostname.start_with?(Socket.gethostname) }
Contributor
Author
There was a problem hiding this comment.
ah, we need the hostnames to get the number_hostname. We could make this change but then we'd need to read the hostfile again to get the number of hosts.
Collaborator
There was a problem hiding this comment.
Oh true, my bad then! Didn't read enough of the diff :D
TApplencourt
approved these changes
Feb 16, 2026
Collaborator
|
Thanks a lot \o/ |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When testing the timeline on Sunspot, we ran into a fail like:
This happened since hostname_id was
nilsince inhostname_id = hostnames.find_index(Socket.gethostname)Socket.gethostnamewas not found in the hostnames list. This was because the hostnames list on sunspot contains hostnames with-hsn0on them:while
Socket.gethostnamereturns justx1921c1s2b0n0.To work around this, this PR will get the index if the element in hostnames starts with the result of
Socket.gethostname. This also raises an error and prints a message if the hostname_id is nil in the future for easier debugging.Thanks to @TApplencourt for advice on solution!