Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small adjusts to start performance studies #1044

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions libensemble/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import logging
import os
import platform
import pstats
import socket
import sys
import time
Expand Down Expand Up @@ -132,10 +131,7 @@ def manager_main(
if libE_specs.get("profile"):
pr.disable()
profile_stats_fname = "manager.prof"

with open(profile_stats_fname, "w") as f:
ps = pstats.Stats(pr, stream=f).sort_stats("cumulative")
ps.print_stats()
pr.dump_stats(profile_stats_fname)

return result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
nworkers, is_manager, libE_specs, _ = parse_args()

libE_specs["profile"] = True
libE_specs["safe_mode"] = False
libE_specs["kill_canceled_sims"] = False

sim_specs = {
"sim_f": sim_f,
Expand All @@ -48,7 +50,7 @@

persis_info = add_unique_random_streams({}, nworkers + 1)

exit_criteria = {"gen_max": 501}
exit_criteria = {"sim_max": 1e5}

# Perform the run
H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs)
Expand All @@ -58,7 +60,7 @@
print("\nlibEnsemble with random sampling has generated enough points")

assert "manager.prof" in os.listdir(), "Expected manager profile not found after run"
os.remove("manager.prof")
# os.remove("manager.prof")

prof_files = [f"worker_{i+1}.prof" for i in range(nworkers)]

Expand All @@ -67,11 +69,11 @@

for file in prof_files:
assert file in os.listdir(), "Expected profile {file} not found after run"
with open(file, "r") as f:
data = f.read().split()
num_worker_funcs_profiled = sum(["worker" in i for i in data])
assert num_worker_funcs_profiled >= 8, (
"Insufficient number of " + "worker functions profiled: " + str(num_worker_funcs_profiled)
)

os.remove(file)
# with open(file, "r") as f:
# data = f.read().split()
# num_worker_funcs_profiled = sum(["worker" in i for i in data])
# assert num_worker_funcs_profiled >= 8, (
# "Insufficient number of " + "worker functions profiled: " + str(num_worker_funcs_profiled)
# )

# os.remove(file)
6 changes: 1 addition & 5 deletions libensemble/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import cProfile
import logging
import logging.handlers
import pstats
import socket
from itertools import count
from pathlib import Path
Expand Down Expand Up @@ -114,10 +113,7 @@ def worker_main(
if libE_specs.get("profile"):
pr.disable()
profile_state_fname = "worker_%d.prof" % (workerID)

with open(profile_state_fname, "w") as f:
ps = pstats.Stats(pr, stream=f).sort_stats("cumulative")
ps.print_stats()
pr.dump_stats(profile_state_fname)


######################################################################
Expand Down
Loading