Skip to content

Commit

Permalink
gc perf fix
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaj Bjorner <[email protected]>
  • Loading branch information
NikolajBjorner committed Aug 6, 2020
1 parent f4ec63f commit a51e40a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/smt/smt_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2007,12 +2007,38 @@ namespace smt {
Reduce the size of v to old_size.
*/
void context::del_clauses(clause_vector & v, unsigned old_size) {
SASSERT(old_size <= v.size());
unsigned num_collect = v.size() - old_size;
if (num_collect == 0)
return;

clause_vector::iterator begin = v.begin() + old_size;
clause_vector::iterator it = v.end();
while (it != begin) {
--it;
del_clause(false, *it);
if (num_collect > 1000) {
uint_set watches;
while (it != begin) {
--it;
clause* c = *it;
remove_lit_occs(*c, get_num_bool_vars());
if (!c->deleted()) {
c->mark_as_deleted(m);
}
watches.insert((~c->get_literal(0)).index());
watches.insert((~c->get_literal(1)).index());
}
for (auto w: watches) {
m_watches[w].remove_deleted();
}
for (it = v.end(); it != begin; ) {
--it;
(*it)->deallocate(m);
}
m_stats.m_num_del_clause += (v.size() - old_size);
}
else {
while (it != begin) {
--it;
del_clause(false, *it);
}
}
v.shrink(old_size);
}
Expand Down
14 changes: 14 additions & 0 deletions src/smt/watch_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ namespace smt {
}
end_cls_core() -= sizeof(clause *);
}

void watch_list::remove_deleted() {
clause_iterator end = end_clause();
clause_iterator it = begin_clause();
clause_iterator prev = it;
unsigned num_deleted = 0;
for (; it != end; ++it) {
if ((*it)->deleted())
++num_deleted;
else
*prev++ = *it;
}
end_cls_core() -= num_deleted * sizeof(clause *);
}

void watch_list::remove_literal(literal l) {
literal * begin = begin_literals();
Expand Down
2 changes: 2 additions & 0 deletions src/smt/watch_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ namespace smt {
}

void remove_clause(clause * c);

void remove_deleted();

void remove_literal(literal l);

Expand Down

0 comments on commit a51e40a

Please sign in to comment.