Skip to content

Commit

Permalink
fix(verifier): request larger stack size for new solver (#5883)
Browse files Browse the repository at this point in the history
In the future we can look at doing a smarter job lowering to datalog
(e.g. not adding every goal into the same giant Horn clause, which was
causing souffle to bump up against the stack). For now, just asking for
a larger stack allows all the Go tests to pass; tested this by running
them with the flag fixed to true.
  • Loading branch information
zrlk committed Oct 6, 2023
1 parent dc4b005 commit 4708608
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions kythe/cxx/verifier/verifier_main.cc
Expand Up @@ -15,6 +15,7 @@
*/

#include <stdio.h>
#include <sys/resource.h>
#include <unistd.h>

#include <string>
Expand Down Expand Up @@ -69,6 +70,11 @@ ABSL_FLAG(bool, use_fast_solver, false,
ABSL_FLAG(bool, print_timing_information, false,
"Print timing information for profiling.");

namespace {
// The fast solver needs extra stack space for modest programs.
constexpr rlim_t kSolverStack = 64L * 1024L * 1024L;
} // namespace

int main(int argc, char** argv) {
GOOGLE_PROTOBUF_VERIFY_VERSION;
kythe::InitializeProgram(argv[0]);
Expand Down Expand Up @@ -139,6 +145,23 @@ invocation and rule syntax.

v.UseFastSolver(absl::GetFlag(FLAGS_use_fast_solver));

if (absl::GetFlag(FLAGS_use_fast_solver)) {
struct rlimit rl;
int r = getrlimit(RLIMIT_STACK, &rl);
if (r != 0) {
perror("failed getting solver stack size");
return 1;
}
if (rl.rlim_cur < kSolverStack) {
rl.rlim_cur = kSolverStack;
r = setrlimit(RLIMIT_STACK, &rl);
if (r != 0) {
perror("failed increasing solver stack size");
return 1;
}
}
}

std::string dbname = "database";
size_t facts = 0;
auto start_read_time = absl::Now();
Expand Down

0 comments on commit 4708608

Please sign in to comment.