Caching foundation for a dependencyGraph which maps dependency relations.#4127
Open
ashprice wants to merge 7 commits into
Open
Caching foundation for a dependencyGraph which maps dependency relations.#4127ashprice wants to merge 7 commits into
ashprice wants to merge 7 commits into
Conversation
Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk> Typo Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk> Added note Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>
Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>
… one to resolve references within all_tasks) Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>
Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>
Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>
Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>
Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an initial PR which lays the groundwork for one that will shortly follow. It introduces lazy caching of pending/completed tasks, a UUID index for pending tasks, the construction of a dependency map, and adds in-place mutation of pending tasks. This roughly halves the instruction count for many reports (though the speed gain from this PR is minor to the one that I will make if it is accepted, about 1.3x for many reports. I gave up waiting for the performance tests in ./performance/ to complete, and instead constructed a smaller, 300 task test database.)
Changes
pending_tasks()andcompleted_tasks()returnconst std::vector<Task>&instead of copying.all_tasks()is deliberately not cached, as it can be very large and is only read once per invocation._pending_indexis lazily built withpending_tasks().get()andmodify()use this instead of scanning the vectors.DependencyGraphhashmap is introduced and built from the pending cache. (A temporary map is created forall_tasks(), in the event thatdependency_scan()must refer to things in all_tasks.) This is not yet consumed byTaskin this PR - that will be the PR to follow.modify()makes updates in-place within the vector by leveraging the_pending_tasksindex. This cache is invalidated in any case where there may be a change of state between the Rust replica and the cached index.pending_tasksandcompleted_tasks.Endnotes
This PR doesn't necessarily bring much by itself, but it's needed to lay the groundwork for DependencyGraph to be used by
getDependencyTasks()andgetBlockedTasks(). Adding in in-place modifications is a somewhat opportunistic addition for the PR, as it's not strictly necessary for core functionality, but it does improve modification performance when running big batch modifications.All tests pass and I am pretty sure this doesn't break anything, but there's a small chance bugs have slipped by me.
This would be my first major contribution to a C++ codebase, and I am not a professional software engineer, so feedback on pretty much everything here is accepted gratefully.