Skip to content

Use the pending tasks cache in the circular dependency check. - #4179

Merged
djmitche merged 1 commit into
GothenburgBitFactory:developfrom
ashprice:is/4178
Aug 25, 2026
Merged

Use the pending tasks cache in the circular dependency check.#4179
djmitche merged 1 commit into
GothenburgBitFactory:developfrom
ashprice:is/4178

Conversation

@ashprice

@ashprice ashprice commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Introduced ahead of the other work to address #4178 .

Main changes:

  1. the dependency graph is traversed using a stack of UUIDs.
  2. The traversal first looks to the modified task, so that modified dependencies are included.
  3. Other dependencies are all checked against the cache with find_pending().
  4. Traversal stops at completed, deleted, or missing dependencies.
  5. Visited UUIDs are marked, so each dependency is only visited once.
  6. The cache is initialized where necessary.

Three tests are introduced:

  • test_completed_not_circular() checks that completed tasks do not cause a positive circularity check.
  • test_circular_with_visited_sibling() makes sure that visited siblings do not get overwritten when the unvisited sibling is popped.
  • test_dependency_modify_with_cold_pending_cache() checks that the pending cache is initialized during modifications. It uses an empty filter because most modify commands warm the cache, but this one doesn't.

There are still remaining issues with empty filters, bulk modifications of completed tasks, and bulk modifications of dependencies in other regards, I plan to address these in a future PR.

Also, this won't bring broader performance improvement on its own, because it doesn't touch the stuff relevant for eg. task ready.

Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>

@djmitche djmitche left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks great!

Comment thread src/dependency.cpp
auto& tdb2 = Context::getContext().tdb2;

std::unordered_set<std::string> visited{task_uuid};
std::vector<std::string> stack;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm curious why the switch from stack to vector?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If there was a reason for this I have forgotten it, I guess I thought it might be more memory efficient at the time but I don't see any reason to think that.

I wrote the original code this PR was based on in early July or late June so I might have had another reason and forgotten about it, it seems I had originally used stack.

@djmitche
djmitche merged commit 5413e71 into GothenburgBitFactory:develop Aug 25, 2026
16 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