Skip to content

Commit 2902422

Browse files
committed
Make fom regex less greedy
From informal testing, making it less greedy can improve the regex matching perf by about 5-7%. Also remove some redundant end-of-string match using `.*`, as we use `re.match` for finding the match.
1 parent 733863b commit 2902422

File tree

31 files changed

+118
-116
lines changed

31 files changed

+118
-116
lines changed

var/ramble/repos/builtin/applications/architecture-check/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ArchitectureCheck(ExecutableApplication):
7474

7575
workload_group("all_workloads", workloads=["standard"])
7676

77-
spack_regex = r"Spack tuple: (?P<platform>\S+)-(?P<os>\S+)-(?P<arch>\S+)"
77+
spack_regex = r"Spack tuple: (?P<platform>\S+?)-(?P<os>\S+?)-(?P<arch>\S+)"
7878

7979
figure_of_merit(
8080
"Spack Platform",

var/ramble/repos/builtin/applications/elk/application.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Elk(ExecutableApplication):
6969
success_criteria(
7070
"prints_done",
7171
mode="string",
72-
match=r".*Elk code stopped.*",
72+
match=r".*?Elk code stopped",
7373
file="{experiment_run_dir}/{experiment_name}.out",
7474
)
7575

@@ -88,7 +88,7 @@ class Elk(ExecutableApplication):
8888
figure_of_merit(
8989
metric,
9090
log_file=output_file,
91-
fom_regex=rf"\s*(?P<metric>{metric})\s+:\s+(?P<value>[0-9]+\.[0-9]*).*",
91+
fom_regex=rf"\s*(?P<metric>{metric})\s+:\s+(?P<value>[0-9]+\.[0-9]*)",
9292
group_name="value",
9393
units="s",
9494
)

var/ramble/repos/builtin/applications/gromacs/application.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ class Gromacs(ExecutableApplication):
392392
figure_of_merit(
393393
"Core Time",
394394
log_file=log_str,
395-
fom_regex=r"\s+Time:\s+(?P<core_time>[0-9]+\.[0-9]+).*",
395+
fom_regex=r"\s+Time:\s+(?P<core_time>[0-9]+\.[0-9]+)",
396396
group_name="core_time",
397397
units="s",
398398
fom_type=FomType.TIME,
@@ -402,7 +402,7 @@ class Gromacs(ExecutableApplication):
402402
"Wall Time",
403403
log_file=log_str,
404404
fom_regex=r"\s+Time:\s+[0-9]+\.[0-9]+\s+"
405-
+ r"(?P<wall_time>[0-9]+\.[0-9]+).*",
405+
+ r"(?P<wall_time>[0-9]+\.[0-9]+)",
406406
group_name="wall_time",
407407
units="s",
408408
fom_type=FomType.TIME,
@@ -412,7 +412,7 @@ class Gromacs(ExecutableApplication):
412412
"Percent Core Time",
413413
log_file=log_str,
414414
fom_regex=r"\s+Time:\s+[0-9]+\.[0-9]+\s+[0-9]+\.[0-9]+\s+"
415-
+ r"(?P<perc_core_time>[0-9]+\.[0-9]+).*",
415+
+ r"(?P<perc_core_time>[0-9]+\.[0-9]+)",
416416
group_name="perc_core_time",
417417
units="%",
418418
fom_type=FomType.MEASURE,
@@ -421,7 +421,7 @@ class Gromacs(ExecutableApplication):
421421
figure_of_merit(
422422
"Nanosecs per day",
423423
log_file=log_str,
424-
fom_regex=r"Performance:\s+" + r"(?P<ns_per_day>[0-9]+\.[0-9]+).*",
424+
fom_regex=r"Performance:\s+" + r"(?P<ns_per_day>[0-9]+\.[0-9]+)",
425425
group_name="ns_per_day",
426426
units="ns/day",
427427
fom_type=FomType.THROUGHPUT,
@@ -431,7 +431,7 @@ class Gromacs(ExecutableApplication):
431431
"Hours per nanosec",
432432
log_file=log_str,
433433
fom_regex=r"Performance:\s+[0-9]+\.[0-9]+\s+"
434-
+ r"(?P<hours_per_ns>[0-9]+\.[0-9]+).*",
434+
+ r"(?P<hours_per_ns>[0-9]+\.[0-9]+)",
435435
group_name="hours_per_ns",
436436
units="hours/ns",
437437
fom_type=FomType.INFO,

var/ramble/repos/builtin/applications/hmmer/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Hmmer(ExecutableApplication):
9797

9898
figure_of_merit(
9999
"Elapsed time",
100-
fom_regex=r"# CPU.*Elapsed:\s+(?P<elapsed_time>[0-9]+:[0-9]+:[0-9]+\.*[0-9]*)\s*$",
100+
fom_regex=r"# CPU.*?Elapsed:\s+(?P<elapsed_time>[0-9]+:[0-9]+:[0-9]+\.*[0-9]*)\s*$",
101101
group_name="elapsed_time",
102102
log_file=out_file,
103103
units="hms",

var/ramble/repos/builtin/applications/hostname/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Hostname(ExecutableApplication):
5757

5858
figure_of_merit(
5959
"possible hostname",
60-
fom_regex=r"(?P<hostname>\S+)\s*",
60+
fom_regex=r"(?P<hostname>\S+)",
6161
group_name="hostname",
6262
units="",
6363
)

var/ramble/repos/builtin/applications/intel-mpi-benchmarks/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,5 +273,5 @@ class IntelMpiBenchmarks(ExecutableApplication):
273273
success_criteria(
274274
"run_to_completion",
275275
mode="string",
276-
match=r".*All processes entering MPI_Finalize",
276+
match=r".*?All processes entering MPI_Finalize",
277277
)

var/ramble/repos/builtin/applications/iperf2/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Iperf2(ExecutableApplication):
106106
figure_of_merit(
107107
"Total BW",
108108
log_file=log_str,
109-
fom_regex=r"\[SUM\]\s.*sec\s.*GBytes\s(?P<bw>.*)\sGbits/sec.*",
109+
fom_regex=r"\[SUM\]\s.*?sec\s.*?GBytes\s(?P<bw>.*)\sGbits/sec",
110110
group_name="bw",
111111
units="Gbits/sec",
112112
)

var/ramble/repos/builtin/applications/lammps/application.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,21 +316,21 @@ class Lammps(ExecutableApplication):
316316
)
317317
figure_of_merit(
318318
"Nanoseconds per day",
319-
fom_regex=r"Performance.*\s+(?P<nspd>[0-9\.]+) (ns|tau)/day",
319+
fom_regex=r"Performance.*?\s+(?P<nspd>[0-9\.]+) (ns|tau)/day",
320320
group_name="nspd",
321321
units="ns/day",
322322
fom_type=FomType.THROUGHPUT,
323323
)
324324
figure_of_merit(
325325
"Hours per nanosecond",
326-
fom_regex=r"Performance.*\s+(?P<hpns>[0-9\.]+) hours/ns",
326+
fom_regex=r"Performance.*?\s+(?P<hpns>[0-9\.]+) hours/ns",
327327
group_name="hpns",
328328
units="hours/ns",
329329
fom_type=FomType.TIME,
330330
)
331331
figure_of_merit(
332332
"Timesteps per second",
333-
fom_regex=r"Performance.*\s+(?P<tsps>[0-9\.]+) timesteps/s",
333+
fom_regex=r"Performance.*?\s+(?P<tsps>[0-9\.]+) timesteps/s",
334334
group_name="tsps",
335335
units="timesteps/s",
336336
fom_type=FomType.THROUGHPUT,

var/ramble/repos/builtin/applications/lulesh/application.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ class Lulesh(ExecutableApplication):
6868
figure_of_merit(
6969
"Time",
7070
log_file=log_str,
71-
fom_regex=r"\s*Elapsed time\s+=\s+(?P<time>[0-9]+\.[0-9]+).*",
71+
fom_regex=r"\s*Elapsed time\s+=\s+(?P<time>[0-9]+\.[0-9]+)",
7272
group_name="time",
7373
units="s",
7474
)
7575

7676
figure_of_merit(
7777
"FOM",
7878
log_file=log_str,
79-
fom_regex=r"\s*FOM\s+=\s+(?P<fom>[0-9]+\.[0-9]+).*",
79+
fom_regex=r"\s*FOM\s+=\s+(?P<fom>[0-9]+\.[0-9]+)",
8080
group_name="fom",
8181
units="z/s",
8282
)
@@ -92,7 +92,7 @@ class Lulesh(ExecutableApplication):
9292
figure_of_merit(
9393
"Grind Time",
9494
log_file=log_str,
95-
fom_regex=r"\s*Grind time \(us/z/c\)\s+=\s+(?P<grind>[0-9]+\.[0-9]+).*",
95+
fom_regex=r"\s*Grind time \(us/z/c\)\s+=\s+(?P<grind>[0-9]+\.[0-9]+)",
9696
group_name="grind",
9797
units="s/element",
9898
)

var/ramble/repos/builtin/applications/minixyce/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class Minixyce(ExecutableApplication):
153153
floating_point_regex = r"\d+\.\d+"
154154
scientific_number_regex = r"[\+\-]*\d+\.\d+[eE][\+\-]*\d+"
155155

156-
success_regex = r"^\s*TIME.*num_GMRES_iters\s*num_GMRES_restarts"
156+
success_regex = r"^\s*TIME.*?num_GMRES_iters\s*num_GMRES_restarts"
157157
success_criteria("valid", mode="string", match=success_regex, file=log_str)
158158

159159
figure_of_merit(

0 commit comments

Comments
 (0)