Commit 82e2289f authored by mvogt's avatar mvogt

[libcontacts] Append contacts in large batches

Batched append slows down the overall throughput, but is necessary
to give interactivity during startup with huge contact counts. With
10000 contacts, the penalty is less than 10% overall, and the app
remains usable during the append period.
parent 9c48a0dd
......@@ -2311,21 +2311,35 @@ void SeasideCache::applyPendingContactUpdates()
const bool partialFetch = !detailTypes.isEmpty();
QList<QContact> &appendedContacts((*it).second);
appendContacts(appendedContacts, type, partialFetch, detailTypes);
m_contactsToAppend.erase(it);
// This list has been processed - have we finished populating the group?
if (type == FilterFavorites && (m_populateProgress != FetchFavorites)) {
makePopulated(FilterFavorites);
qDebug() << "Favorites queried in" << m_timer.elapsed() << "ms";
} else if (type == FilterAll && (m_populateProgress != FetchMetadata)) {
makePopulated(FilterNone);
makePopulated(FilterAll);
qDebug() << "All queried in" << m_timer.elapsed() << "ms";
} else if (type == FilterOnline && (m_populateProgress != FetchOnline)) {
makePopulated(FilterOnline);
qDebug() << "Online queried in" << m_timer.elapsed() << "ms";
const int maxBatchSize = 200;
const int minBatchSize = 50;
if (appendedContacts.count() < maxBatchSize) {
// For a small number of contacts, append all at once
appendContacts(appendedContacts, type, partialFetch, detailTypes);
appendedContacts.clear();
} else {
// Append progressively in batches
appendContacts(appendedContacts.mid(0, minBatchSize), type, partialFetch, detailTypes);
appendedContacts = appendedContacts.mid(minBatchSize);
}
if (appendedContacts.isEmpty()) {
m_contactsToAppend.erase(it);
// This list has been processed - have we finished populating the group?
if (type == FilterFavorites && (m_populateProgress != FetchFavorites)) {
makePopulated(FilterFavorites);
qDebug() << "Favorites queried in" << m_timer.elapsed() << "ms";
} else if (type == FilterAll && (m_populateProgress != FetchMetadata)) {
makePopulated(FilterNone);
makePopulated(FilterAll);
qDebug() << "All queried in" << m_timer.elapsed() << "ms";
} else if (type == FilterOnline && (m_populateProgress != FetchOnline)) {
makePopulated(FilterOnline);
qDebug() << "Online queried in" << m_timer.elapsed() << "ms";
}
}
} else {
QList<QPair<QSet<DetailTypeId>, QList<QContact> > >::iterator it = m_contactsToUpdate.begin();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment