diff options
author | Don Sanders <don.sanders@nokia.com> | 2012-03-30 13:23:40 +0300 |
---|---|---|
committer | Don Sanders <don.sanders@nokia.com> | 2012-03-30 13:23:40 +0300 |
commit | 9754b6850f8171096514e180ac97b0b783e88fd7 (patch) | |
tree | d4f5c1ee797e9c8c6af1f44aa7c1e733f76c081c | |
parent | cd8741b26ac61f537a3be16b67ee0b1131ff3027 (diff) |
Add support for increasing messaging store performance by disabling durable/atomic operations.
For performance testing to see how much synchronous writes cost.
Default uses fsync, and sqlite synchronous=FULL
QMF_NO_DURABILITY disables fsync, uses sqlite synchronous=NORMAL, and is documented.
QMF_NO_SYNCHRONOUS_DB disables fsync, uses sqlite synchronous=OFF, and is not currently document.
Test data - total 100 messages in 13 different folders, medium speed network, fast desktop HD
Default - Avg 13 seconds
14 12:57:50 - 12:58:04
12 13:13:09 - 13:13:21
QMF_NO_DURABILITY - Avg 10 seconds
10 13:02:17 - 13:02:27
09 13:03:39 - 13:03:48
QMF_NO_SYNCHRONOUS_DB - Avg 10 seconds
10 13:19:43 - 13:19:53
10 13:20:45 - 13:20:55
Conclusion NO_DURABILTY and NO_SYNCHRONOUS_DB run at a similar speed about 20%-40% faster than normal.
-rw-r--r-- | doc/src/messaging.qdoc | 5 | ||||
-rw-r--r-- | src/libraries/qmfclient/qmailstore_p.cpp | 20 | ||||
-rw-r--r-- | src/plugins/contentmanagers/qmfstoragemanager/qmfstoragemanager.cpp | 12 |
3 files changed, 37 insertions, 0 deletions
diff --git a/doc/src/messaging.qdoc b/doc/src/messaging.qdoc index 2045815d..39461e1c 100644 --- a/doc/src/messaging.qdoc +++ b/doc/src/messaging.qdoc @@ -78,6 +78,11 @@ or optionally remove unwanted tests from the messagingframework.pro. qmake -r messagingframework.pro DEFINES+=QMF_NO_MESSAGE_SERVICE_EDITOR \endcode +\bold Note: By default QMF operations on the message store are atomic and durable, so long as the underlying OS supports durable writes, e.g. on Linux based systems so long as fsync makes durable writes. Atomic means all of an operation such as a delete/update/add take effect or none of it does. Durable means once an operation is reported to have succeeded it will survive permanently even in the event of a system crash. Ensuring these properties has a considerable performance cost. To increase performance both durability and atomicity can be disabled using the define QMF_NO_DURABILITY e.g.: +\code +qmake -r messagingframework.pro DEFINES+=QMF_NO_DURABILITY +\endcode + \section1 Running Messaging Framework After \c{make install} has run, the following layout should exist in your image directory: diff --git a/src/libraries/qmfclient/qmailstore_p.cpp b/src/libraries/qmfclient/qmailstore_p.cpp index d10ff798..82638334 100644 --- a/src/libraries/qmfclient/qmailstore_p.cpp +++ b/src/libraries/qmfclient/qmailstore_p.cpp @@ -2638,6 +2638,26 @@ bool QMailStorePrivate::initStore() qWarning() << "Unable to reduce page cache size" << query.lastQuery().simplified(); } } +#if defined(QMF_NO_DURABILITY) || defined(QMF_NO_SYNCHRONOUS_DB) +#if defined(QMF_NO_SYNCHRONOUS_DB) + { + // Use sqlite synchronous=OFF does not protect integrity of database does not ensure durability + QSqlQuery query( *database() ); + qWarning() << "Disabling synchronous writes, database may become corrupted!"; + if (!query.exec(QLatin1String("PRAGMA synchronous=OFF;"))) { + qWarning() << "Unable to set synchronous mode to OFF" << query.lastQuery().simplified(); + } + } +#else + { + // Use sqlite synchronous=NORMAL protects integrity of database but does not ensure durability + QSqlQuery query( *database() ); + if (!query.exec(QLatin1String("PRAGMA synchronous=NORMAL;"))) { + qWarning() << "Unable to set synchronous mode to NORMAL" << query.lastQuery().simplified(); + } + } +#endif +#endif #endif if (!QMailContentManagerFactory::init()) { diff --git a/src/plugins/contentmanagers/qmfstoragemanager/qmfstoragemanager.cpp b/src/plugins/contentmanagers/qmfstoragemanager/qmfstoragemanager.cpp index 999a7cc3..ec0b8704 100644 --- a/src/plugins/contentmanagers/qmfstoragemanager/qmfstoragemanager.cpp +++ b/src/plugins/contentmanagers/qmfstoragemanager/qmfstoragemanager.cpp @@ -199,6 +199,10 @@ void syncFile(QSharedPointer<QFile> file) { // Ensure data is flushed to OS before attempting sync file->flush(); +#if defined(QMF_NO_DURABILITY) || defined(QMF_NO_SYNCHRONOUS_DB) + // Durability is disabled + return; +#endif //TODO: Is a Symbian version of this code required? #if defined(Q_OS_WIN) @@ -345,6 +349,9 @@ QMailStore::ErrorCode QmfStorageManager::ensureDurability() { if (_useFullSync) { // More than one file needs to be synchronized +#if !defined(QMF_NO_DURABILITY) && !defined(QMF_NO_SYNCHRONOUS_DB) + + // Durability is not disabled #if defined(Q_OS_WIN) qWarning() << "Unable to call sync on Windows."; #else @@ -352,6 +359,7 @@ QMailStore::ErrorCode QmfStorageManager::ensureDurability() ::sync(); #endif #endif +#endif _useFullSync = false; } else { foreach (QSharedPointer<QFile> file, _openFiles) { @@ -365,12 +373,16 @@ QMailStore::ErrorCode QmfStorageManager::ensureDurability() QMailStore::ErrorCode QmfStorageManager::ensureDurability(const QList<QString> &identifiers) { +#if !defined(QMF_NO_DURABILITY) && !defined(QMF_NO_SYNCHRONOUS_DB) + // Durability is not disabled + // Can't just sync identifiers, also must sync message parts #if defined(Q_OS_WIN) || defined (Q_OS_SYMBIAN) qWarning() << "Unable to call sync in ensureDurability."; #else ::sync(); #endif +#endif return QMailStore::NoError; } |