summaryrefslogtreecommitdiffstats
path: root/tests/genericresourcebenchmark.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-10-28 16:39:16 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-10-28 16:39:16 +0100
commit129333371d28c06d85f75ca579ce17798e615e84 (patch)
tree2ae01db9d26f6f72a74fa77e6937e03304e81a2c /tests/genericresourcebenchmark.cpp
parent20f049b65c4bd8c3d0c16bbf398641675648a93f (diff)
downloadsink-129333371d28c06d85f75ca579ce17798e615e84.tar.gz
sink-129333371d28c06d85f75ca579ce17798e615e84.zip
Made pipeline preprocessing synchronous.
Instead of having the asynchronous preprocessor concept with different pipelines for new/modify/delete we have a single pipeline with synchronous preprocessors that act upon new/modify/delete. This keeps the code simpler due to lack of asynchronity and keeps the new/modify/delete operations together (which at least for the indexing makes a lot of sense). Not supporting asynchronity is ok because the tasks done in preprocessing are not cpu intensive (if they were we had a problem since they are directly involved in the round-trip time), and the main cost comes from i/o, meaning we don't gain much by doing multithreading. Costly tasks (such as full-text indexing) should rather be implemented as post-processing, since that doesn't increase the round-trip time directly, and eventually consistent is typically good enough for that.
Diffstat (limited to 'tests/genericresourcebenchmark.cpp')
-rw-r--r--tests/genericresourcebenchmark.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/tests/genericresourcebenchmark.cpp b/tests/genericresourcebenchmark.cpp
index b8635d7..fbe0d12 100644
--- a/tests/genericresourcebenchmark.cpp
+++ b/tests/genericresourcebenchmark.cpp
@@ -60,6 +60,25 @@ static QByteArray createEntityBuffer()
60 return QByteArray(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); 60 return QByteArray(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize());
61} 61}
62 62
63class IndexUpdater : public Akonadi2::Preprocessor {
64public:
65 void newEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE
66 {
67 for (int i = 0; i < 10; i++) {
68 Index ridIndex(QString("index.index%1").arg(i).toLatin1(), transaction);
69 ridIndex.add("foo", uid);
70 }
71 }
72
73 void modifiedEntity(const QByteArray &key, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE
74 {
75 }
76
77 void deletedEntity(const QByteArray &key, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE
78 {
79 }
80};
81
63/** 82/**
64 * Benchmark write performance of generic resource implementation including queues and pipeline. 83 * Benchmark write performance of generic resource implementation including queues and pipeline.
65 */ 84 */
@@ -124,19 +143,9 @@ private Q_SLOTS:
124 143
125 auto eventFactory = QSharedPointer<TestEventAdaptorFactory>::create(); 144 auto eventFactory = QSharedPointer<TestEventAdaptorFactory>::create();
126 const QByteArray resourceIdentifier = "org.kde.test.instance1"; 145 const QByteArray resourceIdentifier = "org.kde.test.instance1";
127 auto eventIndexer = new Akonadi2::SimpleProcessor("eventIndexer", [eventFactory, resourceIdentifier](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity, Akonadi2::Storage::Transaction &transaction) { 146 auto indexer = QSharedPointer<IndexUpdater>::create();
128 auto adaptor = eventFactory->createAdaptor(entity); 147
129 Akonadi2::ApplicationDomain::Event event(resourceIdentifier, state.key(), -1, adaptor); 148 pipeline->setPreprocessors("event", QVector<Akonadi2::Preprocessor*>() << indexer.data());
130 Akonadi2::ApplicationDomain::TypeImplementation<Akonadi2::ApplicationDomain::Event>::index(event, transaction);
131
132 //Create a bunch of indexes
133 for (int i = 0; i < 10; i++) {
134 Index ridIndex(QString("index.index%1").arg(i).toLatin1(), transaction);
135 ridIndex.add("foo", event.identifier());
136 }
137 });
138
139 pipeline->setPreprocessors("event", Akonadi2::Pipeline::NewPipeline, QVector<Akonadi2::Preprocessor*>() << eventIndexer);
140 pipeline->setAdaptorFactory("event", eventFactory); 149 pipeline->setAdaptorFactory("event", eventFactory);
141 150
142 TestResource resource("org.kde.test.instance1", pipeline); 151 TestResource resource("org.kde.test.instance1", pipeline);