Commit 3e48fc9b authored by one's avatar one
Browse files

[xcl-lens] Change log_entries to set

parent a95f20e8
......@@ -5,8 +5,8 @@ import pandas as pd
class RcclLogParser:
def __init__(self, verbose=False, hosts=None, ranks=None):
# (host, rank, content) -> None
self.log_entries = dict()
# Deduplicated set of (host, rank, content) tuples
self.log_entries: set[tuple[str, int, str]] = set()
# Verbosity flag used by report sections
self._verbose = verbose
......@@ -94,7 +94,7 @@ class RcclLogParser:
return
if self._ranks and rank not in self._ranks:
return
self.log_entries[(host, rank, content)] = None
self.log_entries.add((host, rank, content))
return
# Backward-compatible fallback for logs without host/pid/tid prefix
......@@ -103,13 +103,13 @@ class RcclLogParser:
rank, content = int(match.group(1)), match.group(2)
if self._ranks and rank not in self._ranks:
return
self.log_entries[("-", rank, content)] = None
self.log_entries.add(("-", rank, content))
def _report_sys(self):
"""Search patterns and print pre-defined strings if matched"""
print("===> System Information:\n")
reported = set()
for (_, _, content), _ in self.log_entries.items():
for _, _, content in self.log_entries:
for pattern, out in self.sys_patterns.items():
if re.search(pattern, content, re.IGNORECASE):
reported.add(out if out is not None else content)
......@@ -123,7 +123,7 @@ class RcclLogParser:
print("===> User-defined Environment Variables:\n")
env_vars = {}
pattern = re.compile(r"((?:N|R)CCL_\w+)\s+set(?: by environment)? to\s+(.+)")
for (_, _, content), _ in self.log_entries.items():
for _, _, content in self.log_entries:
m = pattern.search(content)
if m:
var_name, var_value = m.group(1), m.group(2)
......@@ -143,7 +143,7 @@ class RcclLogParser:
ib_rows = []
pattern_ib = re.compile(r"NET/IB\s+:\s+GPU Direct RDMA Enabled for HCA\s+(\d+)\s+'([^']+)'")
for (host, rank, content), _ in self.log_entries.items():
for host, rank, content in self.log_entries:
m = pattern_ib.search(content)
if m:
hca_no, hca_id = m.groups()
......@@ -176,7 +176,7 @@ class RcclLogParser:
r"GPU Direct RDMA Enabled for GPU\s+(\S+)\s*/\s*"
r"HCA\s+(\d+)\s*\(distance\s+([^)]*)\),\s*read\s+([01])"
)
for (host, rank, content), _ in self.log_entries.items():
for host, rank, content in self.log_entries:
m = pattern_gpu.search(content)
if m:
gpu, hca_no, distance, read_flag = m.groups()
......@@ -245,7 +245,7 @@ class RcclLogParser:
print(f"===> {title}:\n")
# Filter relevant log lines using the provided filter function
data = [(h, r, c) for (h, r, c), _ in self.log_entries.items() if filter_func(c)]
data = [(h, r, c) for h, r, c in self.log_entries if filter_func(c)]
if not data:
print(" (No data found)\n")
return
......@@ -370,7 +370,7 @@ class RcclLogParser:
r"(?: \[(\w+)\])?\s+via\s+([\w/]+)"
)
for (host, rank, content), _ in self.log_entries.items():
for host, rank, content in self.log_entries:
m = pattern.search(content)
if m:
channel, src, dst, type_, transport = m.groups()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment