Skip to content

Speed-up connect_default_error_handlers - #492

Merged
woutdenolf merged 1 commit into
mainfrom
speedup_mxpress_analysis
Aug 11, 2026
Merged

Speed-up connect_default_error_handlers#492
woutdenolf merged 1 commit into
mainfrom
speedup_mxpress_analysis

Conversation

@woutdenolf

@woutdenolf woutdenolf commented Aug 5, 2026

Copy link
Copy Markdown
Member

Quick win for MX workflows before refactoring the graph analysis: #40 (comment)

import time

from ewoks import load_graph
from ewoksppf.bindings import EwoksWorkflow

t0 = time.perf_counter()

ewoksgraph = load_graph("MXPressE", root_module="bes.flows")

t1 = time.perf_counter()

workflow = EwoksWorkflow(ewoksgraph)

t2 = time.perf_counter()

print("Ewoks:", t1 - t0)
print("Ppf:", t2 - t1)

Before this PR:

Ewoks: 2.6934584959999484
Ppf: 0.043437874999654014

After this PR:

Ewoks: 0.3990270340000279
Ppf: 0.04421490299864672

This quick win is useful when switching from BES flask servers to Ewoks workers. The BES flask server is caching the result of load_graph() with a wapper called load_workflow()

import time
import tempfile


from bes.job_manager.workflow_utils import load_workflow, parse_workflow_name

with tempfile.TemporaryDirectory() as tmpdirname:

    t0 = time.perf_counter()

    _, path = parse_workflow_name("MXPressE")
    load_workflow(path, cache_directory=tmpdirname)

    t1 = time.perf_counter()

    load_workflow(path, cache_directory=tmpdirname)

    t2 = time.perf_counter()

    print("First:", t1 - t0)
    print("Second:", t2 - t1)

Before this PR:

First: 2.5053138860002946
Second: 0.0052449080012593186

After this PR:

First: 0.26184313200064935
Second: 0.005358114998671226

So caching gains ~0.3 sec on my PC after this fix. Hardly worth it as opposed to the original 2.5 sec which is significant.

Ping @olofsvensson @LudoBroche

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@woutdenolf
woutdenolf force-pushed the speedup_mxpress_analysis branch 2 times, most recently from ac8613c to a996fa5 Compare August 5, 2026 20:42
@woutdenolf
woutdenolf force-pushed the speedup_mxpress_analysis branch from a996fa5 to 39a5298 Compare August 5, 2026 20:49
Comment on lines -42 to -46
for node_id in set(nodes_without_error_handlers):
for ancestor_id in node_ancestors(graph, node_id):
if ancestor_id in default_error_handlers:
nodes_without_error_handlers.remove(node_id)
break

@woutdenolf woutdenolf Aug 5, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove nodes that have any of the default error handlers as ancestor:

BEFORE: remove a node when one of its ancestors is a default error handler.

Comment thread src/ewokscore/graph/error_handlers.py
@woutdenolf
woutdenolf marked this pull request as ready for review August 5, 2026 21:27
@woutdenolf
woutdenolf requested a review from LudoBroche August 5, 2026 21:27
Comment thread src/ewokscore/graph/error_handlers.py
@woutdenolf
woutdenolf merged commit 3bbd3cd into main Aug 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants