Skip to content

Optimization: Code tree literal occupancy - #1056

Open
Synrom wants to merge 8 commits into
vprover:masterfrom
Synrom:optimization/code-tree-literal-occupancy
Open

Synrom wants to merge 8 commits into
vprover:masterfrom
Synrom:optimization/code-tree-literal-occupancy

Conversation

@Synrom

@Synrom Synrom commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Optimizes Code trees by ignoring occupied query literals.

That is when an earlier indexed literal only matches a single query literal, that query literal can be ignored moving forward inside the tree.

@shalashaska117

Copy link
Copy Markdown
Contributor

Could you add tests covering backtracking, equality orientations and subsumption resolution, plus a before/after benchmark? It would help to check whether the saved matching work outweighs the cost of computing occupied positions.

Comment thread Indexing/CodeTree.hpp

inline bool isExclusive() const
{
return std::has_single_bit(bitmask);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't we save an overflow bit so that we know when there are "unsaved" overflown bits and therefore this function would return the wrong value?

Comment thread Indexing/CodeTree.hpp Outdated
struct LitInfoOccupation {
static constexpr unsigned CAPACITY = 64;

static LitInfoOccupation createEmptyOccupation()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this really needed?

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.

I removed it now

CodeTree::LitInfoOccupation ClauseCodeTree::ClauseMatcher::occupiedPositions()
{
LitInfoOccupation occupied;
// A truncated domain could falsely appear to contain just one position.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah okay I see the case I asked about below is handled here.

Comment thread Indexing/ClauseCodeTree.cpp Outdated
return occupied;
}

for(auto& lm : lms) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be const if possible, I don't see any reason why not (apart from having to add a const getILS?).

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.

Made it const now

eagerResults.reset();

RSTAT_CTR_INC("LiteralMatcher::init");
if (!seekOnlySuccess && !prepareLiteral()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you write a comment why this is needed now?

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.

I've added a comment

{
void init(const CodeTree& tree, FlatTerm* ft_) {
CodeTree::Matcher</*removing*/false,/*checkRange=*/false>::init(tree,tree.getEntryPoint(), 0, 0);
CodeTree::Matcher</*removing*/false,/*checkRange=*/false>::init(tree,tree.getEntryPoint(), LitInfoOccupation(), 0, 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could be made a default value, similarly here. Is a default LitInfoOccupation() value a correct one in all cases?

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.

I've made LitInfoOccupation() the default now, but kept it here to maintain the following arguments from before.

@mezpusz

mezpusz commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

TPTP FOL Discount:

run 0 unsat: 9168 (0) sat: 1042 (0) cputime: 60786.71 s instructions: 223481241 Mi memory: 1803241.82 MB
run 1 unsat: 9174 (6) sat: 1044 (2) cputime: 60420.06 s instructions: 223330463 Mi memory: 1815523.09 MB

TPTP FOL Otter:

run 0 unsat: 9304 (0) sat: 1026 (0) cputime: 66220.80 s instructions: 223238846 Mi memory: 2069794.32 MB
run 1 unsat: 9328 (24) sat: 1026 (0) cputime: 65536.47 s instructions: 222893120 Mi memory: 2102873.76 MB

@Synrom

Synrom commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

@shalashaska117 I think most of these cases are already covered by the existing code tree tests.
I've also added a test for subsumption and one for subsumption resolution combining equalities, backtracking and occupations.

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.

3 participants