diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2016-02-21 09:42:11 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2016-02-21 09:42:11 +0000 |
commit | 5380ed0fad80744e3093a6fb6f13f8d8a7b2e03a (patch) | |
tree | af15eeb3b7f96efca86f4d05afc9df694962e020 /plugins/Dbx_mdb/src | |
parent | e151d6242dafb449fae9784e19e8122c44b57095 (diff) |
dbx_lmdb: speed optimization
git-svn-id: http://svn.miranda-ng.org/main/trunk@16317 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb/src')
-rw-r--r-- | plugins/Dbx_mdb/src/dbcontacts.cpp | 32 | ||||
-rw-r--r-- | plugins/Dbx_mdb/src/dbintf.cpp | 5 | ||||
-rw-r--r-- | plugins/Dbx_mdb/src/dbintf.h | 6 | ||||
-rw-r--r-- | plugins/Dbx_mdb/src/dbmodulechain.cpp | 10 | ||||
-rw-r--r-- | plugins/Dbx_mdb/src/dbsettings.cpp | 28 | ||||
-rw-r--r-- | plugins/Dbx_mdb/src/ui.h | 27 |
6 files changed, 50 insertions, 58 deletions
diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp index cee0d1dedf..7c225f25d0 100644 --- a/plugins/Dbx_mdb/src/dbcontacts.cpp +++ b/plugins/Dbx_mdb/src/dbcontacts.cpp @@ -208,9 +208,14 @@ BOOL CDbxMdb::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) }
MDB_val keyc = { sizeof(int), &ccMeta->contactID }, datac = { sizeof(ccMeta->dbc), &ccMeta->dbc };
- txn_ptr trnlck(m_pMdbEnv);
- mdb_put(trnlck, m_dbContacts, &keyc, &datac, 0);
- trnlck.commit();
+
+ for (;; Remap())
+ {
+ txn_ptr trnlck(m_pMdbEnv);
+ MDB_CHECK(mdb_put(trnlck, m_dbContacts, &keyc, &datac, 0), 1);
+ if (trnlck.commit())
+ break;
+ }
return 0;
}
@@ -237,9 +242,14 @@ BOOL CDbxMdb::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) }
MDB_val keyc = { sizeof(int), &ccMeta->contactID }, datac = { sizeof(ccMeta->dbc), &ccMeta->dbc };
- txn_ptr trnlck(m_pMdbEnv);
- mdb_put(trnlck, m_dbContacts, &keyc, &datac, 0);
- trnlck.commit();
+
+ for (;; Remap())
+ {
+ txn_ptr trnlck(m_pMdbEnv);
+ MDB_CHECK(mdb_put(trnlck, m_dbContacts, &keyc, &datac, 0), 1);
+ if (trnlck.commit())
+ break;
+ }
return 0;
}
@@ -276,10 +286,11 @@ void CDbxMdb::FillContacts() {
LIST<DBCachedContact> arContacts(10);
- txn_ptr trnlck(m_pMdbEnv);
- //mdb_open(trnlck, "contacts", MDB_INTEGERKEY, &m_dbContacts);
{
- cursor_ptr cursor(trnlck, m_dbContacts);
+ mir_cslock lck(m_csDbAccess);
+
+ txn_ptr_ro trnlck(m_txn);
+ cursor_ptr_ro cursor(m_curContacts);
MDB_val key, data;
while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) {
@@ -297,7 +308,8 @@ void CDbxMdb::FillContacts() }
m_contactCount = 0;
- for (int i = 0; i < arContacts.getCount(); i++) {
+ for (int i = 0; i < arContacts.getCount(); i++)
+ {
DBCachedContact *cc = arContacts[i];
CheckProto(cc, "");
diff --git a/plugins/Dbx_mdb/src/dbintf.cpp b/plugins/Dbx_mdb/src/dbintf.cpp index a036f5090f..93606df78c 100644 --- a/plugins/Dbx_mdb/src/dbintf.cpp +++ b/plugins/Dbx_mdb/src/dbintf.cpp @@ -117,8 +117,13 @@ int CDbxMdb::Load(bool bSkipInit) {
mdb_txn_begin(m_pMdbEnv, nullptr, MDB_RDONLY, &m_txn);
+
mdb_cursor_open(m_txn, m_dbEvents, &m_curEvents);
mdb_cursor_open(m_txn, m_dbEventsSort, &m_curEventsSort);
+ mdb_cursor_open(m_txn, m_dbSettings, &m_curSettings);
+ mdb_cursor_open(m_txn, m_dbModules, &m_curModules);
+ mdb_cursor_open(m_txn, m_dbContacts, &m_curContacts);
+
mdb_txn_reset(m_txn);
}
diff --git a/plugins/Dbx_mdb/src/dbintf.h b/plugins/Dbx_mdb/src/dbintf.h index 210bf9f785..c1a8569a2c 100644 --- a/plugins/Dbx_mdb/src/dbintf.h +++ b/plugins/Dbx_mdb/src/dbintf.h @@ -249,6 +249,8 @@ protected: // settings
MDB_dbi m_dbSettings;
+ MDB_cursor *m_curSettings;
+
int m_codePage;
HANDLE hService, hHook;
@@ -256,6 +258,8 @@ protected: // contacts
MDB_dbi m_dbContacts;
+ MDB_cursor *m_curContacts;
+
int m_contactCount, m_dwMaxContactId;
void GatherContactHistory(MCONTACT hContact, LIST<EventItem> &items);
@@ -274,6 +278,8 @@ protected: // modules
MDB_dbi m_dbModules;
+ MDB_cursor *m_curModules;
+
HANDLE m_hModHeap;
LIST<ModuleName> m_lMods, m_lOfs;
LIST<char> m_lResidentSettings;
diff --git a/plugins/Dbx_mdb/src/dbmodulechain.cpp b/plugins/Dbx_mdb/src/dbmodulechain.cpp index cc988e3f66..77ad7c8481 100644 --- a/plugins/Dbx_mdb/src/dbmodulechain.cpp +++ b/plugins/Dbx_mdb/src/dbmodulechain.cpp @@ -42,15 +42,13 @@ int CDbxMdb::InitModuleNames(void) {
m_maxModuleID = 0;
+ mir_cslock lck(m_csDbAccess);
txn_ptr_ro trnlck(m_txn);
- //mdb_open(trnlck, "modules", MDB_INTEGERKEY, &m_dbModules);
-
- cursor_ptr cursor(trnlck, m_dbModules);
- if (!cursor)
- return 1;
+ cursor_ptr_ro cursor(m_curModules);
MDB_val key, data;
- while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) {
+ while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0)
+ {
DBModuleName *pmod = (DBModuleName*)data.mv_data;
if (pmod->dwSignature != DBMODULENAME_SIGNATURE)
DatabaseCorruption(NULL);
diff --git a/plugins/Dbx_mdb/src/dbsettings.cpp b/plugins/Dbx_mdb/src/dbsettings.cpp index 99d99668e9..1d6caac3f9 100644 --- a/plugins/Dbx_mdb/src/dbsettings.cpp +++ b/plugins/Dbx_mdb/src/dbsettings.cpp @@ -61,18 +61,6 @@ int CDbxMdb::GetContactSettingWorker(MCONTACT contactID, LPCSTR szModule, LPCSTR // the db format can't tolerate more than 255 bytes of space (incl. null) for settings+module name
int settingNameLen = (int)strlen(szSetting);
int moduleNameLen = (int)strlen(szModule);
- if (settingNameLen > 0xFE) {
-#ifdef _DEBUG
- OutputDebugStringA("GetContactSettingWorker() got a > 255 setting name length. \n");
-#endif
- return 1;
- }
- if (moduleNameLen > 0xFE) {
-#ifdef _DEBUG
- OutputDebugStringA("GetContactSettingWorker() got a > 255 module name length. \n");
-#endif
- return 1;
- }
mir_cslock lck(m_csDbAccess);
@@ -524,18 +512,6 @@ STDMETHODIMP_(BOOL) CDbxMdb::DeleteContactSetting(MCONTACT contactID, LPCSTR szM // the db format can't tolerate more than 255 bytes of space (incl. null) for settings+module name
int settingNameLen = (int)strlen(szSetting);
int moduleNameLen = (int)strlen(szModule);
- if (settingNameLen > 0xFE) {
-#ifdef _DEBUG
- OutputDebugStringA("DeleteContactSetting() got a > 255 setting name length. \n");
-#endif
- return 1;
- }
- if (moduleNameLen > 0xFE) {
-#ifdef _DEBUG
- OutputDebugStringA("DeleteContactSetting() got a > 255 module name length. \n");
-#endif
- return 1;
- }
MCONTACT saveContact = contactID;
{
@@ -577,7 +553,6 @@ STDMETHODIMP_(BOOL) CDbxMdb::EnumContactSettings(MCONTACT contactID, DBCONTACTEN return -1;
int result = 0;
- mir_cslock lck(m_csDbAccess);
DBSettingKey keySearch;
keySearch.dwContactID = contactID;
@@ -586,8 +561,9 @@ STDMETHODIMP_(BOOL) CDbxMdb::EnumContactSettings(MCONTACT contactID, DBCONTACTEN LIST<char> arSettings(50);
{
+ mir_cslock lck(m_csDbAccess);
txn_ptr_ro trnlck(m_txn);
- cursor_ptr cursor(trnlck, m_dbSettings);
+ cursor_ptr_ro cursor(m_curSettings);
MDB_val key = { sizeof(keySearch), &keySearch }, data;
if (mdb_cursor_get(cursor, &key, &data, MDB_SET_RANGE) == MDB_SUCCESS) {
diff --git a/plugins/Dbx_mdb/src/ui.h b/plugins/Dbx_mdb/src/ui.h index d723e684c0..007104377e 100644 --- a/plugins/Dbx_mdb/src/ui.h +++ b/plugins/Dbx_mdb/src/ui.h @@ -4,21 +4,9 @@ class CSelectCryptoDialog : public CDlgBase {
CCtrlCombo m_combo;
CCtrlData m_descr;
- //CCtrlCustom m_descr;
CRYPTO_PROVIDER **m_provs;
size_t m_provscount;
CRYPTO_PROVIDER *m_selected;
-public:
- CSelectCryptoDialog(CRYPTO_PROVIDER **provs, size_t count) :
- CDlgBase(g_hInst, IDD_SELECT_CRYPTOPROVIDER),
- m_combo(this, IDC_SELECTCRYPT_COMBO),
- m_descr(this, IDC_CRYPTOPROVIDER_DESCR),
- m_provs(provs),
- m_provscount(count),
- m_selected(nullptr)
- {
- m_combo.OnChange = Callback(this, &CSelectCryptoDialog::OnComboChanged);
- }
void OnInitDialog()
{
@@ -28,7 +16,7 @@ public: m_combo.AddStringA(prov->pszName, i);
}
m_combo.SetCurSel(0);
- SetDescr(m_provs[0]);
+ m_descr.SetText(m_provs[0]->ptszDescr);
}
void OnClose()
@@ -38,12 +26,19 @@ public: void OnComboChanged(CCtrlCombo*)
{
- SetDescr(m_provs[m_combo.GetItemData(m_combo.GetCurSel())]);
+ m_descr.SetText(m_provs[m_combo.GetItemData(m_combo.GetCurSel())]->ptszDescr);
}
- void SetDescr(CRYPTO_PROVIDER *prov)
+public:
+ CSelectCryptoDialog(CRYPTO_PROVIDER **provs, size_t count) :
+ CDlgBase(g_hInst, IDD_SELECT_CRYPTOPROVIDER),
+ m_combo(this, IDC_SELECTCRYPT_COMBO),
+ m_descr(this, IDC_CRYPTOPROVIDER_DESCR),
+ m_provs(provs),
+ m_provscount(count),
+ m_selected(nullptr)
{
- m_descr.SetText(prov->ptszDescr);
+ m_combo.OnChange = Callback(this, &CSelectCryptoDialog::OnComboChanged);
}
inline CRYPTO_PROVIDER* GetSelected()
|