Cache interpretation of trees and avoid excessive recomputation of predicates/trees - #91
Merged
Jekannadar merged 1 commit intoAug 13, 2026
Conversation
Contributor
There was a problem hiding this comment.
Benchmark CoSy
Details
| Benchmark suite | Current: b5a8825 | Previous: be71b5d | Ratio |
|---|---|---|---|
benchmarks/test_benchmark_maximal_elements.py::test_benchmark_maximal_elements |
10.43306182813801 iter/sec (stddev: 0.00022465880145587798) |
9.608281351562356 iter/sec (stddev: 0.010017085420616013) |
0.92 |
benchmarks/test_benchmark_maze.py::test_benchmark_maze |
4.359626682760569 iter/sec (stddev: 0.020393723606656953) |
3.9235166334572096 iter/sec (stddev: 0.018797551923491352) |
0.90 |
benchmarks/test_benchmark_maze_contains.py::test_benchmark_maze_contains |
4.110375478673194 iter/sec (stddev: 0.023216042955672603) |
3.5391214334611916 iter/sec (stddev: 0.025877608823890046) |
0.86 |
benchmarks/test_benchmark_maze_loopfree.py::test_benchmark_maze_loopfree |
4.1489713872557 iter/sec (stddev: 0.024998383997361814) |
3.8477221717914887 iter/sec (stddev: 0.02072136799063595) |
0.93 |
This comment was automatically generated by workflow using github-action-benchmark.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #91 +/- ##
===========================================
+ Coverage 71.99% 73.02% +1.03%
===========================================
Files 37 39 +2
Lines 2810 2944 +134
Branches 476 494 +18
===========================================
+ Hits 2023 2150 +127
- Misses 683 686 +3
- Partials 104 108 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Jekannadar
force-pushed
the
feature/performance-tuning
branch
3 times, most recently
from
August 13, 2026 17:28
c6e2676 to
807c1fb
Compare
Jekannadar
force-pushed
the
feature/performance-tuning
branch
from
August 13, 2026 17:31
807c1fb to
b5a8825
Compare
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.
Adds a cache to the Tree class,
_interpreted. Trees are immutable, as long as the interpretation is deterministic, having a cache on the Tree itself is fine.Modify
_generate_new_trees:Currently, whenever it is called, it combines all arguments with all parameters, and then later duplicates are thrown away downstream.
_RuleProgressintroduces some simple tracking, making sure to only compute new combinations:This gets some speedup across all CoSy tests and benchmarks, CoSy-Luigi speeds up a bit, and on projects that are basically using CLS to compute a powerset, this gets a very heavy speedup.
Note:
_RuleProgressobjects is keyed on the id ofRHSRuleinstead of itself. WhileRHSRuleis hashable, its hash is rather expensive, and Pythons built-in id works just the same for this use-case.