Skip to content

Fix reference cycle memory leak in _run_node#95

Open
shenald-dev wants to merge 5 commits into
mainfrom
jules-bolt-perf-refactor-run-node-12458985514428149869
Open

Fix reference cycle memory leak in _run_node#95
shenald-dev wants to merge 5 commits into
mainfrom
jules-bolt-perf-refactor-run-node-12458985514428149869

Conversation

@shenald-dev
Copy link
Copy Markdown
Owner

Refactored WorkflowEngine._run_node to accept dependency_tasks: tuple[asyncio.Task[Any], ...] instead of the mutable tasks dictionary.

  • What changed: Extracted dependency mapping logic out of the _run_node coroutine and into the caller (execute). _run_node now strictly receives the specific sequence of awaited Task dependencies it needs.
  • Why it matters: Passing the entire mutable tasks dictionary into the async coroutine created a reference cycle memory leak (tasks dict -> Task object -> Coroutine -> tasks dict). Extracting dependencies into a pre-resolved tuple breaks the cycle and cleanly decouples the async task runner from shared state.
  • How it was verified: All 32 pytest tests passed cleanly.
  • Remaining risks: Very low. The logic evaluates the same tasks; the only difference is that the dictionary lookup happens synchronously before creating the background task.

PR created automatically by Jules for task 12458985514428149869 started by @shenald-dev

Co-authored-by: shenald-dev <245350826+shenald-dev@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@shenald-dev
Copy link
Copy Markdown
Owner Author

Hey @shenald-dev, heads up — this PR has merge conflicts with main.

To fix:

git checkout jules-bolt-perf-refactor-run-node-12458985514428149869
git fetch origin && git merge origin/main

@shenald-dev shenald-dev added bug Something isn't working refactor labels May 12, 2026
@shenald-dev
Copy link
Copy Markdown
Owner Author

Thanks for the clear explanation and fix for the memory leak. Please resolve the merge conflicts with main as noted in the comments to proceed with merging.

Reviewed — quality: high

@google-labs-jules
Copy link
Copy Markdown
Contributor

Hey @shenald-dev, heads up — this PR has merge conflicts with main.

To fix:

git checkout jules-bolt-perf-refactor-run-node-12458985514428149869
git fetch origin && git merge origin/main

I have successfully merged the latest changes from main and resolved the merge conflicts. The _run_node tests still pass cleanly.

Co-authored-by: shenald-dev <245350826+shenald-dev@users.noreply.github.com>
@shenald-dev
Copy link
Copy Markdown
Owner Author

🔄 Re-evaluating based on recent changes:

Nice fix for the reference cycle. Consider adding a brief note in the changelog about the memory leak resolution for future reference.

Reviewed — quality: high

@google-labs-jules
Copy link
Copy Markdown
Contributor

🔄 Re-evaluating based on recent changes:

Nice fix for the reference cycle. Consider adding a brief note in the changelog about the memory leak resolution for future reference.

Reviewed — quality: high

Thank you for the review. I have added a brief note to CHANGELOG.md detailing the memory leak resolution for future reference.

Co-authored-by: shenald-dev <245350826+shenald-dev@users.noreply.github.com>
@shenald-dev
Copy link
Copy Markdown
Owner Author

Hey @shenald-dev, heads up — this PR has merge conflicts with main.

To fix:

git checkout jules-bolt-perf-refactor-run-node-12458985514428149869
git fetch origin && git merge origin/main

@google-labs-jules
Copy link
Copy Markdown
Contributor

Hey @shenald-dev, heads up — this PR has merge conflicts with main.

To fix:

git checkout jules-bolt-perf-refactor-run-node-12458985514428149869
git fetch origin && git merge origin/main

I have successfully merged the latest changes from main and resolved the merge conflicts in .jules/bolt.md. All tests are passing.

Co-authored-by: shenald-dev <245350826+shenald-dev@users.noreply.github.com>
@shenald-dev shenald-dev added the documentation Improvements or additions to documentation label May 20, 2026
@shenald-dev
Copy link
Copy Markdown
Owner Author

Well-explained fix for the memory leak. The refactoring is sound, tests pass, and merge conflicts are resolved. The change reduces coupling and eliminates the reference cycle as intended.

Reviewed — quality: high

@google-labs-jules
Copy link
Copy Markdown
Contributor

Well-explained fix for the memory leak. The refactoring is sound, tests pass, and merge conflicts are resolved. The change reduces coupling and eliminates the reference cycle as intended.

Reviewed — quality: high

Acknowledged.

@shenald-dev
Copy link
Copy Markdown
Owner Author

Hey @shenald-dev, heads up — this PR has merge conflicts with main.

To fix:

git checkout jules-bolt-perf-refactor-run-node-12458985514428149869
git fetch origin && git merge origin/main

@google-labs-jules
Copy link
Copy Markdown
Contributor

Hey @shenald-dev, heads up — this PR has merge conflicts with main.

To fix:

git checkout jules-bolt-perf-refactor-run-node-12458985514428149869
git fetch origin && git merge origin/main

I have successfully merged the latest changes from main and resolved the new merge conflicts in .jules/bolt.md. All tests are passing.

Co-authored-by: shenald-dev <245350826+shenald-dev@users.noreply.github.com>
@shenald-dev
Copy link
Copy Markdown
Owner Author

Well-explained fix for the reference cycle memory leak. The refactoring is clean, tests pass, and merge conflicts have been resolved. Consider adding a brief note in the changelog about the memory leak resolution (already done per CHANGELOG.md changes).

Reviewed — quality: high

@google-labs-jules
Copy link
Copy Markdown
Contributor

Well-explained fix for the reference cycle memory leak. The refactoring is clean, tests pass, and merge conflicts have been resolved. Consider adding a brief note in the changelog about the memory leak resolution (already done per CHANGELOG.md changes).

Reviewed — quality: high

Acknowledged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation needs-review refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant