-
Notifications
You must be signed in to change notification settings - Fork 284
Collect complexity statistics of solver queries #5266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collect complexity statistics of solver queries #5266
Conversation
Introduces a functionality to track and collect the complexity of individual solver queries. For SAT solvers we collect the number of clauses, literals, and variables. The functionality matches solver queries to the SSA steps that produced them. After running the solver, we produce a JSON report that matches program line to GOTO instruction to SSA step to solver hardness. At present the collection is command-line optional and only works with the default SAT solver (minisat2). Extension to other SAT and SMT solvers should be possible. A simple regression test is included. Note: the solver-hardness structure lives in the minisat2 and is accessible via the interface of hardness-collector (which minisat2 inherits from). Hence to find out if symex should collect the statistics one must try-cast `prop` to `hardness-collector`. `prop` is part of the `solvert` but not directly accessible from `decision-procedure`. So we also had to extend the interface that initialises the SSA conversion (to include `prop` as well).
|
|
||
| void convert_symex_target_equation( | ||
| symex_target_equationt &equation, | ||
| decision_proceduret &decision_procedure, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undo to keep it general
src/goto-checker/bmc_util.cpp
Outdated
|
|
||
| // convert SSA | ||
| equation.convert(decision_procedure); | ||
| equation.convert(property_decider.get_decision_procedure()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undo to keep it general
src/goto-checker/bmc_util.cpp
Outdated
| #include <linking/static_lifetime_init.h> | ||
|
|
||
| #include <solvers/decision_procedure.h> | ||
| #include <solvers/flattening/boolbv.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
src/goto-checker/bmc_util.cpp
Outdated
|
|
||
| convert_symex_target_equation( | ||
| equation, property_decider.get_decision_procedure(), ui_message_handler); | ||
| convert_symex_target_equation(equation, property_decider, ui_message_handler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undo
src/goto-checker/bmc_util.h
Outdated
| void convert_symex_target_equation( | ||
| symex_target_equationt &, | ||
| decision_proceduret &, | ||
| goto_symex_property_decidert &, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undo
|
|
||
| /// Provides management of goal variables that encode properties | ||
| class goto_symex_property_decidert | ||
| class goto_symex_property_decidert : public hardness_collectort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no changes required in this class
| equation_generated(false), | ||
| property_decider(options, ui_message_handler, equation, ns) | ||
| { | ||
| if(options.is_set("write-solver-stats-to")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should happen in solver_factoryt
| { | ||
| if(options.is_set("write-solver-stats-to")) | ||
| { | ||
| with_solver_hardness(property_decider, [](solver_hardnesst &hardness) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass decision procedure instead of property decider:
with_solver_hardness(property_decider.get_decision_procedure()).produce_report();
|
|
||
| #include <solvers/decision_procedure.h> | ||
| #include <solvers/hardness_collector.h> | ||
| #include <solvers/prop/prop.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no reference to prop in this class
| #include "symex_target.h" | ||
|
|
||
| class decision_proceduret; | ||
| class propt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no changes required in this file
025a967 to
6ae064e
Compare
|
|
||
| /// Additional reporting that may result from the underlying solver, no-op by | ||
| /// default. | ||
| virtual void report() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is just for the hardness stats right now should this be reflected in the name of this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say no.
a404049 to
fbb2da1
Compare
| ^\[main.assertion.\d+\] line \d+ assertion a \+ b \< 10: FAILURE$ | ||
| ^VERIFICATION FAILED$ | ||
| ^Valid JSON File$ | ||
| \"SAT_hardness\": \{(\"Clauses\": \d+|\"Variables\": \d+|\"Literals\": \d+), (\"Clauses\": \d+|\"Variables\": \d+|\"Literals\": \d+), (\"Clauses\": \d+|\"Variables\": \d+|\"Literals\": \d+)\} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as tests go this isn’t very exciting, but I couldn’t figure out a good way to put specific values here either; Any changes to symex or solvers would invalidate any test that’s checking for concrete values here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could check that there is something non-zero, at least.
peterschrammel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now. Thanks, @hannes-steffenhagen-diffblue, for cleaning this up!
|
|
||
| /// Additional reporting that may result from the underlying solver, no-op by | ||
| /// default. | ||
| virtual void report() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say no.
| ^\[main.assertion.\d+\] line \d+ assertion a \+ b \< 10: FAILURE$ | ||
| ^VERIFICATION FAILED$ | ||
| ^Valid JSON File$ | ||
| \"SAT_hardness\": \{(\"Clauses\": \d+|\"Variables\": \d+|\"Literals\": \d+), (\"Clauses\": \d+|\"Variables\": \d+|\"Literals\": \d+), (\"Clauses\": \d+|\"Variables\": \d+|\"Literals\": \d+)\} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could check that there is something non-zero, at least.
NlightNFotis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Introduces a functionality to track and collect the complexity of individual
solver queries. For SAT solvers we collect the number of clauses, literals, and
variables. The functionality matches solver queries to the SSA steps that
produced them. After running the solver, we produce a JSON report that matches
program line to GOTO instruction to SSA step to solver hardness.
At present the collection is command-line optional and only works with the
default SAT solver (minisat2). Extension to other SAT and SMT solvers should be
possible.
Supercedes #5159