From d29d97231c58c48d69c856131ad080fae17981e8 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Thu, 12 May 2011 20:13:55 +0100 Subject: [PATCH] Metric refresh performance improvement (nosync) The SQLITE database syncs (writes) to the metricDB file after every atomic transaction. As the size of the database grows this becomes very expensive (suspect it is writing the entire DB). To avoid this behaviour the Metric refresh code opens and commits a LUW for the entire refresh. This has shown to improve the performance of the metric refresh quite dramatically (50% reduction in overall time to complete a metric refresh). Big props to Fredrik Lingvall for detailed analysis and profiling of the code to identify the inefficiencies. --- src/MetricAggregator.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/MetricAggregator.cpp b/src/MetricAggregator.cpp index 8c2c61086..e1e71280b 100644 --- a/src/MetricAggregator.cpp +++ b/src/MetricAggregator.cpp @@ -81,6 +81,9 @@ void MetricAggregator::refreshMetrics() dbStatus.insert(filename, add); } + // begin LUW -- byproduct of turning off sync (nosync) + dbaccess->connection().transaction(); + // Delete statistics for non-existant ride files QHash::iterator d; for (d = dbStatus.begin(); d != dbStatus.end(); ++d) { @@ -170,6 +173,9 @@ void MetricAggregator::refreshMetrics() out << "METRIC REFRESH ENDS: " << QDateTime::currentDateTime().toString() + "\r\n"; log.close(); + // end LUW -- now syncs DB + dbaccess->connection().commit(); + main->isclean = true; dataChanged(); // notify models/views