Skip to content

Commit

Permalink
Improve performance test's tolerance for background tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
ragibson committed Jun 4, 2024
1 parent 81b287d commit fa7f24b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions tests/test_parallel_leiden_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import unittest
import warnings

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


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

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

def test_larger_singlelayer_graph_few_runs(self):
"""Single-threaded equivalent is 25 runs on G(n=10000, m=40000)."""
"""Single-threaded equivalent is 50 runs on G(n=10000, m=40000)."""
G = generate_connected_ER(n=10000, m=40000, directed=False)
gammas = np.linspace(0.0, 2.0, 25)
gammas = np.linspace(0.0, 2.0, 50)
parallelization = self.run_singlelayer_graph_parallelization(G, gammas)
self.assertGreater(parallelization, PERFORMANCE_TARGET_RELATIVE_TO_PERFECT_SCALING)

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

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

gammas = np.linspace(0.0, 2.0, 5)
omegas = np.linspace(0.0, 2.0, 5)
gammas = np.linspace(0.0, 2.0, 7)
omegas = np.linspace(0.0, 2.0, 7)
parallelization = self.run_multilayer_graph_parallelization(G_intralayer, G_interlayer,
layer_membership, gammas, omegas)
self.assertGreater(parallelization, PERFORMANCE_TARGET_RELATIVE_TO_PERFECT_SCALING)
Expand Down

0 comments on commit fa7f24b

Please sign in to comment.