summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorGereon Kremer <gereon.kremer@cs.rwth-aachen.de>2021-03-22 22:09:55 +0100
committerGitHub <noreply@github.com>2021-03-22 21:09:55 +0000
commit442bc26b6ce093efed14bfd6764dac30bfdf918f (patch)
tree2c3452bb40116de7e9e0437c29aea654324fc7eb /src/main
parent134985065820077d2628023b9b72f78471392968 (diff)
Move statistics from the driver into the SmtEngine (#6170)
This PR does some refactoring on how we handle statistics in the driver, and some minor cleanup along the way. The SmtEngine now has dedicated statistics for the data collected within the driver and provides utility functions to set them. The driver pushes the collected statistics to the SmtEngine instead of adding them itself to the statistics registry. The node manager no longer holds a statistics registry (that nobody used anymore anyway) The command executor no longer holds a pointer to the SmtEngine itself. The pointer is not necessary and seems to become stale after we call reset on the command executor (which, luckily, we don't seem to do usually) The main motivation for this change is to make the whole statistics infrastructure private to the library and not exporting it to the outside world.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/command_executor.cpp8
-rw-r--r--src/main/command_executor.h8
-rw-r--r--src/main/driver_unified.cpp34
-rw-r--r--src/main/main.cpp2
-rw-r--r--src/main/main.h6
-rw-r--r--src/main/signal_handlers.cpp5
6 files changed, 8 insertions, 55 deletions
diff --git a/src/main/command_executor.cpp b/src/main/command_executor.cpp
index a343b4a37..551880b98 100644
--- a/src/main/command_executor.cpp
+++ b/src/main/command_executor.cpp
@@ -50,9 +50,7 @@ void printStatsIncremental(std::ostream& out, const std::string& prvsStatsString
CommandExecutor::CommandExecutor(Options& options)
: d_solver(new api::Solver(&options)),
d_symman(new SymbolManager(d_solver.get())),
- d_smtEngine(d_solver->getSmtEngine()),
d_options(options),
- d_stats(),
d_result()
{
}
@@ -66,15 +64,13 @@ CommandExecutor::~CommandExecutor()
void CommandExecutor::flushStatistics(std::ostream& out) const
{
// SmtEngine + node manager flush statistics is part of the call below
- d_smtEngine->flushStatistics(out);
- d_stats.flushInformation(out);
+ getSmtEngine()->flushStatistics(out);
}
void CommandExecutor::safeFlushStatistics(int fd) const
{
// SmtEngine + node manager flush statistics is part of the call below
- d_smtEngine->safeFlushStatistics(fd);
- d_stats.safeFlushInformation(fd);
+ getSmtEngine()->safeFlushStatistics(fd);
}
bool CommandExecutor::doCommand(Command* cmd)
diff --git a/src/main/command_executor.h b/src/main/command_executor.h
index 48761b7ad..0dea41383 100644
--- a/src/main/command_executor.h
+++ b/src/main/command_executor.h
@@ -52,9 +52,7 @@ class CommandExecutor
* symbol manager.
*/
std::unique_ptr<SymbolManager> d_symman;
- SmtEngine* d_smtEngine;
Options& d_options;
- StatisticsRegistry d_stats;
api::Result d_result;
public:
@@ -82,11 +80,7 @@ class CommandExecutor
api::Result getResult() const { return d_result; }
void reset();
- StatisticsRegistry& getStatisticsRegistry() {
- return d_stats;
- }
-
- SmtEngine* getSmtEngine() { return d_smtEngine; }
+ SmtEngine* getSmtEngine() const { return d_solver->getSmtEngine(); }
/**
* Flushes statistics to a file descriptor.
diff --git a/src/main/driver_unified.cpp b/src/main/driver_unified.cpp
index 846bef5be..d2b676e82 100644
--- a/src/main/driver_unified.cpp
+++ b/src/main/driver_unified.cpp
@@ -15,6 +15,7 @@
#include <stdio.h>
#include <unistd.h>
+#include <chrono>
#include <cstdlib>
#include <cstring>
#include <fstream>
@@ -38,7 +39,6 @@
#include "parser/parser_builder.h"
#include "smt/command.h"
#include "util/result.h"
-#include "util/statistics_registry.h"
using namespace std;
using namespace CVC4;
@@ -59,9 +59,6 @@ namespace CVC4 {
/** A pointer to the CommandExecutor (the signal handlers need it) */
CVC4::main::CommandExecutor* pExecutor = nullptr;
- /** A pointer to the totalTime driver stat (the signal handlers need it) */
- CVC4::TimerStat* pTotalTime = nullptr;
-
}/* CVC4::main namespace */
}/* CVC4 namespace */
@@ -82,10 +79,7 @@ void printUsage(Options& opts, bool full) {
int runCvc4(int argc, char* argv[], Options& opts) {
- // Timer statistic
- pTotalTime = new TimerStat("driver::totalTime");
- pTotalTime->start();
-
+ std::chrono::time_point totalTimeStart = std::chrono::steady_clock::now();
// For the signal handlers' benefit
pOptions = &opts;
@@ -186,14 +180,6 @@ int runCvc4(int argc, char* argv[], Options& opts) {
int returnValue = 0;
{
- // Timer statistic
- RegisterStatistic statTotalTime(&pExecutor->getStatisticsRegistry(),
- pTotalTime);
-
- // Filename statistics
- ReferenceStat<std::string> s_statFilename("driver::filename", filenameStr);
- RegisterStatistic statFilenameReg(&pExecutor->getStatisticsRegistry(),
- &s_statFilename);
// notify SmtEngine that we are starting to parse
pExecutor->getSmtEngine()->notifyStartParsing(filenameStr);
@@ -471,16 +457,10 @@ int runCvc4(int argc, char* argv[], Options& opts) {
// or other on_exit/atexit stuff.
_exit(returnValue);
#endif /* CVC4_COMPETITION_MODE */
+ pExecutor->getSmtEngine()->setResultStatistic(result.toString());
+ std::chrono::duration totalTime = std::chrono::steady_clock::now() - totalTimeStart;
+ pExecutor->getSmtEngine()->setTotalTimeStatistic(std::chrono::duration<double>(totalTime).count());
- ReferenceStat<api::Result> s_statSatResult("driver::sat/unsat", result);
- RegisterStatistic statSatResultReg(&pExecutor->getStatisticsRegistry(),
- &s_statSatResult);
-
- pTotalTime->stop();
-
- // Tim: I think that following comment is out of date?
- // Set the global executor pointer to nullptr first. If we get a
- // signal while dumping statistics, we don't want to try again.
pExecutor->flushOutputStreams();
#ifdef CVC4_DEBUG
@@ -494,12 +474,8 @@ int runCvc4(int argc, char* argv[], Options& opts) {
#endif /* CVC4_DEBUG */
}
- // On exceptional exit, these are leaked, but that's okay... they
- // need to be around in that case for main() to print statistics.
- delete pTotalTime;
delete pExecutor;
- pTotalTime = nullptr;
pExecutor = nullptr;
signal_handlers::cleanup();
diff --git a/src/main/main.cpp b/src/main/main.cpp
index 7e0ed1e83..eb313c3bd 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -32,7 +32,6 @@
#include "parser/parser_builder.h"
#include "parser/parser_exception.h"
#include "util/result.h"
-#include "util/statistics.h"
using namespace std;
using namespace CVC4;
@@ -68,7 +67,6 @@ int main(int argc, char* argv[]) {
*opts.getErr() << "(error \"" << e << "\")" << endl;
}
if(opts.getStatistics() && pExecutor != NULL) {
- pTotalTime->stop();
pExecutor->flushStatistics(*opts.getErr());
}
}
diff --git a/src/main/main.h b/src/main/main.h
index 37430b507..b769bee7d 100644
--- a/src/main/main.h
+++ b/src/main/main.h
@@ -20,9 +20,6 @@
#include "base/exception.h"
#include "cvc4autoconfig.h"
#include "options/options.h"
-#include "util/statistics.h"
-#include "util/statistics_registry.h"
-#include "util/stats_timer.h"
#ifndef CVC4__MAIN__MAIN_H
#define CVC4__MAIN__MAIN_H
@@ -41,9 +38,6 @@ extern const std::string* progName;
/** A reference for use by the signal handlers to print statistics */
extern CVC4::main::CommandExecutor* pExecutor;
-/** A reference for use by the signal handlers to print statistics */
-extern CVC4::TimerStat* pTotalTime;
-
/**
* If true, will not spin on segfault even when CVC4_DEBUG is on.
* Useful for nightly regressions, noninteractive performance runs
diff --git a/src/main/signal_handlers.cpp b/src/main/signal_handlers.cpp
index f3f32c4cd..ccd6c0b19 100644
--- a/src/main/signal_handlers.cpp
+++ b/src/main/signal_handlers.cpp
@@ -40,7 +40,6 @@
#include "options/options.h"
#include "smt/smt_engine.h"
#include "util/safe_print.h"
-#include "util/statistics.h"
using CVC4::Exception;
using namespace std;
@@ -61,10 +60,6 @@ void print_statistics()
{
if (pOptions != NULL && pOptions->getStatistics() && pExecutor != NULL)
{
- if (pTotalTime != NULL && pTotalTime->running())
- {
- pTotalTime->stop();
- }
pExecutor->safeFlushStatistics(STDERR_FILENO);
}
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback