Skip to content

Commit fa7f24b

Browse files
committed
Improve performance test's tolerance for background tasks
1 parent 81b287d commit fa7f24b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/test_parallel_leiden_performance.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
import unittest
1313
import warnings
1414

15-
# this set of tests ensures that we achieve >= 90% parallel performance
16-
# compared to perfect scaling of single-threaded jobs to multiple cores
17-
PERFORMANCE_TARGET_RELATIVE_TO_PERFECT_SCALING = 0.90
15+
# this set of tests ensures that we achieve >= 75% parallel performance compared to perfect scaling of
16+
# single-threaded jobs to multiple cores (with no memory contention). This threshold will be decreased in
17+
# determine_target_parallelization_speedup() if the background CPU utilization exceeds 20%.
18+
PERFORMANCE_TARGET_RELATIVE_TO_PERFECT_SCALING = 0.75
1819

1920

2021
def mock_calculation(_):
@@ -39,7 +40,7 @@ def determine_target_parallelization_speedup(num_calculations=32):
3940

4041
sleep(5) # sleep to increase stability of the CPU utilization check
4142
cpu_utilization = psutil.cpu_percent()
42-
if cpu_utilization > 10:
43+
if cpu_utilization > 20:
4344
PERFORMANCE_TARGET_RELATIVE_TO_PERFECT_SCALING = 0.5
4445
warnings.warn(f"System CPU utilization is non-negligible during parallel performance test! "
4546
f"Dropping performance scaling target to 50%.")
@@ -103,9 +104,9 @@ def test_tiny_singlelayer_graph_many_runs(self):
103104
self.assertGreater(parallelization, PERFORMANCE_TARGET_RELATIVE_TO_PERFECT_SCALING)
104105

105106
def test_larger_singlelayer_graph_few_runs(self):
106-
"""Single-threaded equivalent is 25 runs on G(n=10000, m=40000)."""
107+
"""Single-threaded equivalent is 50 runs on G(n=10000, m=40000)."""
107108
G = generate_connected_ER(n=10000, m=40000, directed=False)
108-
gammas = np.linspace(0.0, 2.0, 25)
109+
gammas = np.linspace(0.0, 2.0, 50)
109110
parallelization = self.run_singlelayer_graph_parallelization(G, gammas)
110111
self.assertGreater(parallelization, PERFORMANCE_TARGET_RELATIVE_TO_PERFECT_SCALING)
111112

@@ -125,16 +126,16 @@ def test_tiny_multilayer_graph_many_runs(self):
125126
self.assertGreater(parallelization, PERFORMANCE_TARGET_RELATIVE_TO_PERFECT_SCALING)
126127

127128
def test_larger_multilayer_graph_few_runs(self):
128-
"""Single-threaded equivalent is 25 runs on approximately G(n=2500, m=15000)."""
129+
"""Single-threaded equivalent is 49 runs on approximately G(n=2500, m=15000)."""
129130
G_intralayer, layer_membership = generate_multilayer_intralayer_SBM(
130131
copying_probability=0.9, p_in=0.15, p_out=0.05, first_layer_membership=[0] * 50 + [1] * 50, num_layers=25
131132
)
132133
interlayer_edges = [(100 * layer + v, 100 * layer + v + 100)
133134
for layer in range(25 - 1) for v in range(100)]
134135
G_interlayer = ig.Graph(interlayer_edges, directed=True)
135136

136-
gammas = np.linspace(0.0, 2.0, 5)
137-
omegas = np.linspace(0.0, 2.0, 5)
137+
gammas = np.linspace(0.0, 2.0, 7)
138+
omegas = np.linspace(0.0, 2.0, 7)
138139
parallelization = self.run_multilayer_graph_parallelization(G_intralayer, G_interlayer,
139140
layer_membership, gammas, omegas)
140141
self.assertGreater(parallelization, PERFORMANCE_TARGET_RELATIVE_TO_PERFECT_SCALING)

0 commit comments

Comments
 (0)