From b625033115c8cb5258de813c7e666c12bece324e Mon Sep 17 00:00:00 2001 From: "Harper, Jason M" Date: Wed, 28 Aug 2024 10:01:48 -0700 Subject: [PATCH 1/4] fix parse of cgroup cpusets --- perf-postprocess.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/perf-postprocess.py b/perf-postprocess.py index 08d4dac..aa66b96 100644 --- a/perf-postprocess.py +++ b/perf-postprocess.py @@ -254,6 +254,23 @@ def get_all_data_lines(input_file_path): return meta_data_lines, perf_events_lines, perf_data_lines +# return the number of cpus in a set +# example sets: +# simple range: "0-95" +# individual cpus: "1+4+5+9" +# individual cpus and range(s): "1+4-7+9+12-14" +def count_cpus_in_set(cpu_set): + count = 0 + subsets = cpu_set.split("+") + for subset in subsets: + if "-" in subset: + low_high = subset.split("-") + count += int(low_high[1]) - int(low_high[0]) + 1 + else: + count += 1 + return count + + # get_metadata def get_metadata_as_dict(meta_data_lines, txns=None): meta_data = {} @@ -312,14 +329,7 @@ def get_metadata_as_dict(meta_data_lines, txns=None): assert len(docker_HASH) == len(docker_SETS) meta_data["CPUSETS"] = {} for i, docker_SET in enumerate(docker_SETS): - if "-" in docker_SET: # range of cpus - num_of_cpus = ( - int(docker_SET.split("-")[1]) - - int(docker_SET.split("-")[0]) - + 1 - ) - else: # either one cpu, or a list of cpus separated by + sign - num_of_cpus = len(docker_SET.split("+")) + num_of_cpus = count_cpus_in_set(docker_SET) meta_data["CPUSETS"][docker_HASH[i]] = num_of_cpus elif line.startswith("Percpu mode"): @@ -844,11 +854,11 @@ def substitute_event_in_expression( if event_df.shape == (1,): # system wide if "sys" not in evaluated_expressions: evaluated_expressions["sys"] = exp_to_evaluate.replace( - "[" + event + "]", str(event_df[0]) + "[" + event + "]", str(event_df.iloc[0]) ) else: evaluated_expressions["sys"] = evaluated_expressions["sys"].replace( - "[" + event + "]", str(event_df[0]) + "[" + event + "]", str(event_df.iloc[0]) ) else: for index in event_df.index: From 8c4f1519b9bc54bad6152b7a6996a59a4e11b789 Mon Sep 17 00:00:00 2001 From: "Harper, Jason M" Date: Wed, 28 Aug 2024 10:02:04 -0700 Subject: [PATCH 2/4] use specific js library versions --- src/base.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/base.html b/src/base.html index f4796d7..49e0b1a 100644 --- a/src/base.html +++ b/src/base.html @@ -10,10 +10,10 @@ - - - - + + + + From bb0a07d80cc8d3af0966bffc9685552b98d519cf Mon Sep 17 00:00:00 2001 From: "Harper, Jason M" Date: Wed, 28 Aug 2024 10:02:14 -0700 Subject: [PATCH 3/4] roll version --- _version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_version.txt b/_version.txt index 347f583..9df886c 100644 --- a/_version.txt +++ b/_version.txt @@ -1 +1 @@ -1.4.1 +1.4.2 From edff0c3bc2dda287fe56cef0455e92172ce04ede Mon Sep 17 00:00:00 2001 From: "Harper, Jason M" Date: Wed, 28 Aug 2024 11:14:03 -0700 Subject: [PATCH 4/4] update black code formatter --- perf-postprocess.py | 12 ++++++------ requirements.txt | 2 +- src/perf_helpers.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/perf-postprocess.py b/perf-postprocess.py index aa66b96..a4a996f 100644 --- a/perf-postprocess.py +++ b/perf-postprocess.py @@ -552,9 +552,11 @@ def extract_dataframe(perf_data_lines, meta_data, perf_mode): # fix metric name X.1, X.2, etc -> just X perf_data_df["metric"] = perf_data_df.apply( - lambda x: ".".join(x["metric"].split(".")[:-1]) - if len(re.findall(r"^[0-9]*$", x["metric"].split(".")[-1])) > 0 - else x["metric"], + lambda x: ( + ".".join(x["metric"].split(".")[:-1]) + if len(re.findall(r"^[0-9]*$", x["metric"].split(".")[-1])) > 0 + else x["metric"] + ), axis=1, ) @@ -1026,9 +1028,7 @@ def generate_metrics( + ( "System" if perf_mode == Mode.System - else "CPU" - if perf_mode == Mode.CPU - else "Socket" + else "CPU" if perf_mode == Mode.CPU else "Socket" ) + " mode" ) diff --git a/requirements.txt b/requirements.txt index 790b011..1b4aa88 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -black==22.8.0 +black==24.8.0 flake8 pytype simpleeval diff --git a/src/perf_helpers.py b/src/perf_helpers.py index 69cc2a0..19e0638 100644 --- a/src/perf_helpers.py +++ b/src/perf_helpers.py @@ -148,7 +148,7 @@ def nmi_watchdog_enabled(): return None try: nmi_watchdog_status = int(proc_output.decode().strip()) - except (ValueError) as e: + except ValueError as e: logging.warning(f"Failed to interpret nmi_watchdog status: {e}") return None return nmi_watchdog_status == 1