Title: [125627] trunk/Source/WebCore
Revision
125627
Author
commit-qu...@webkit.org
Date
2012-08-14 18:18:25 -0700 (Tue, 14 Aug 2012)

Log Message

IndexedDB: add tracing to IDBLevelDBBackingStore
https://bugs.webkit.org/show_bug.cgi?id=93914

Patch by Alec Flett <alecfl...@chromium.org> on 2012-08-14
Reviewed by Tony Chang.

Add a bunch of trace events to the lower level
database layer, to separate database slowness
from core IDB slowness.

Also moving findKeyInIndex into IDBLevelDBBackingStore to
eventually make it const.

No new tests, just adding debug logging.

* Modules/indexeddb/IDBLevelDBBackingStore.cpp:
(WebCore::IDBLevelDBBackingStore::open):
(WebCore::IDBLevelDBBackingStore::deleteDatabase):
(WebCore::IDBLevelDBBackingStore::getObjectStores):
(WebCore::IDBLevelDBBackingStore::createObjectStore):
(WebCore::IDBLevelDBBackingStore::deleteObjectStore):
(WebCore::IDBLevelDBBackingStore::getObjectStoreRecord):
(WebCore):
(WebCore::IDBLevelDBBackingStore::putObjectStoreRecord):
(WebCore::IDBLevelDBBackingStore::clearObjectStore):
(WebCore::IDBLevelDBBackingStore::deleteObjectStoreRecord):
(WebCore::IDBLevelDBBackingStore::keyExistsInObjectStore):
(WebCore::IDBLevelDBBackingStore::getIndexes):
(WebCore::IDBLevelDBBackingStore::createIndex):
(WebCore::IDBLevelDBBackingStore::deleteIndex):
(WebCore::IDBLevelDBBackingStore::putIndexDataForRecord):
(WebCore::IDBLevelDBBackingStore::findKeyInIndex):
(WebCore::IDBLevelDBBackingStore::getPrimaryKeyViaIndex):
(WebCore::IDBLevelDBBackingStore::keyExistsInIndex):
(WebCore::IDBLevelDBBackingStore::openObjectStoreCursor):
(WebCore::IDBLevelDBBackingStore::openIndexKeyCursor):
(WebCore::IDBLevelDBBackingStore::openIndexCursor):
(WebCore::IDBLevelDBBackingStore::Transaction::commit):
(WebCore::IDBLevelDBBackingStore::Transaction::rollback):
* Modules/indexeddb/IDBLevelDBBackingStore.h:
(IDBLevelDBBackingStore):
* Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
(WebCore):
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::onAbort):
(WebCore::IDBTransaction::onComplete):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125626 => 125627)


--- trunk/Source/WebCore/ChangeLog	2012-08-15 00:56:02 UTC (rev 125626)
+++ trunk/Source/WebCore/ChangeLog	2012-08-15 01:18:25 UTC (rev 125627)
@@ -1,3 +1,51 @@
+2012-08-14  Alec Flett  <alecfl...@chromium.org>
+
+        IndexedDB: add tracing to IDBLevelDBBackingStore
+        https://bugs.webkit.org/show_bug.cgi?id=93914
+
+        Reviewed by Tony Chang.
+
+        Add a bunch of trace events to the lower level
+        database layer, to separate database slowness
+        from core IDB slowness.
+
+        Also moving findKeyInIndex into IDBLevelDBBackingStore to
+        eventually make it const.
+
+        No new tests, just adding debug logging.
+
+        * Modules/indexeddb/IDBLevelDBBackingStore.cpp:
+        (WebCore::IDBLevelDBBackingStore::open):
+        (WebCore::IDBLevelDBBackingStore::deleteDatabase):
+        (WebCore::IDBLevelDBBackingStore::getObjectStores):
+        (WebCore::IDBLevelDBBackingStore::createObjectStore):
+        (WebCore::IDBLevelDBBackingStore::deleteObjectStore):
+        (WebCore::IDBLevelDBBackingStore::getObjectStoreRecord):
+        (WebCore):
+        (WebCore::IDBLevelDBBackingStore::putObjectStoreRecord):
+        (WebCore::IDBLevelDBBackingStore::clearObjectStore):
+        (WebCore::IDBLevelDBBackingStore::deleteObjectStoreRecord):
+        (WebCore::IDBLevelDBBackingStore::keyExistsInObjectStore):
+        (WebCore::IDBLevelDBBackingStore::getIndexes):
+        (WebCore::IDBLevelDBBackingStore::createIndex):
+        (WebCore::IDBLevelDBBackingStore::deleteIndex):
+        (WebCore::IDBLevelDBBackingStore::putIndexDataForRecord):
+        (WebCore::IDBLevelDBBackingStore::findKeyInIndex):
+        (WebCore::IDBLevelDBBackingStore::getPrimaryKeyViaIndex):
+        (WebCore::IDBLevelDBBackingStore::keyExistsInIndex):
+        (WebCore::IDBLevelDBBackingStore::openObjectStoreCursor):
+        (WebCore::IDBLevelDBBackingStore::openIndexKeyCursor):
+        (WebCore::IDBLevelDBBackingStore::openIndexCursor):
+        (WebCore::IDBLevelDBBackingStore::Transaction::commit):
+        (WebCore::IDBLevelDBBackingStore::Transaction::rollback):
+        * Modules/indexeddb/IDBLevelDBBackingStore.h:
+        (IDBLevelDBBackingStore):
+        * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
+        (WebCore):
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::onAbort):
+        (WebCore::IDBTransaction::onComplete):
+
 2012-08-14  Hayato Ito  <hay...@chromium.org>
 
         Refactor EventDispatcher, moving code to make actual changes easier to review later.

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp (125626 => 125627)


--- trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp	2012-08-15 00:56:02 UTC (rev 125626)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp	2012-08-15 01:18:25 UTC (rev 125627)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 #include "IDBLevelDBBackingStore.h"
+#include "IDBTracing.h"
 
 #if ENABLE(INDEXED_DATABASE)
 #if USE(LEVELDB)
@@ -200,6 +201,7 @@
 
 PassRefPtr<IDBBackingStore> IDBLevelDBBackingStore::open(SecurityOrigin* securityOrigin, const String& pathBaseArg, const String& fileIdentifier, IDBFactoryBackendImpl* factory)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::open");
     String pathBase = pathBaseArg;
 
     OwnPtr<LevelDBComparator> comparator = adoptPtr(new Comparator());
@@ -357,6 +359,7 @@
 
 bool IDBLevelDBBackingStore::deleteDatabase(const String& name)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::deleteDatabase");
     RefPtr<LevelDBTransaction> transaction = LevelDBTransaction::create(m_db.get());
 
     int64_t databaseId;
@@ -397,6 +400,7 @@
 
 void IDBLevelDBBackingStore::getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::getObjectStores");
     const Vector<char> startKey = ObjectStoreMetaDataKey::encode(databaseId, 1, 0);
     const Vector<char> stopKey = ObjectStoreMetaDataKey::encodeMaxKey(databaseId);
 
@@ -508,6 +512,7 @@
 
 bool IDBLevelDBBackingStore::createObjectStore(int64_t databaseId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::createObjectStore");
     ASSERT(m_currentTransaction);
     int64_t objectStoreId = getNewObjectStoreId(m_currentTransaction.get(), databaseId);
     if (objectStoreId < 0)
@@ -584,6 +589,7 @@
 
 void IDBLevelDBBackingStore::deleteObjectStore(int64_t databaseId, int64_t objectStoreId)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::deleteObjectStore");
     ASSERT(m_currentTransaction);
 
     String objectStoreName;
@@ -604,6 +610,7 @@
 
 String IDBLevelDBBackingStore::getObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey& key)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::getObjectStoreRecord");
     const Vector<char> leveldbKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, key);
     Vector<char> data;
 
@@ -662,6 +669,7 @@
 
 bool IDBLevelDBBackingStore::putObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey& key, const String& value, ObjectStoreRecordIdentifier* recordIdentifier)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::putObjectStoreRecord");
     ASSERT(key.isValid());
     ASSERT(m_currentTransaction);
     int64_t version = getNewVersionNumber(m_currentTransaction.get(), databaseId, objectStoreId);
@@ -686,6 +694,7 @@
 
 void IDBLevelDBBackingStore::clearObjectStore(int64_t databaseId, int64_t objectStoreId)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::clearObjectStore");
     ASSERT(m_currentTransaction);
     const Vector<char> startKey = KeyPrefix(databaseId, objectStoreId, 0).encode();
     const Vector<char> stopKey = KeyPrefix(databaseId, objectStoreId + 1, 0).encode();
@@ -700,6 +709,7 @@
 
 void IDBLevelDBBackingStore::deleteObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier* recordIdentifier)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::deleteObjectStoreRecord");
     ASSERT(m_currentTransaction);
     const LevelDBRecordIdentifier* levelDBRecordIdentifier = static_cast<const LevelDBRecordIdentifier*>(recordIdentifier);
 
@@ -774,6 +784,7 @@
 
 bool IDBLevelDBBackingStore::keyExistsInObjectStore(int64_t databaseId, int64_t objectStoreId, const IDBKey& key, ObjectStoreRecordIdentifier* foundRecordIdentifier)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::keyExistsInObjectStore");
     ASSERT(m_currentTransaction);
     const Vector<char> leveldbKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, key);
     Vector<char> data;
@@ -840,6 +851,7 @@
 
 void IDBLevelDBBackingStore::getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::getIndexes");
     const Vector<char> startKey = IndexMetaDataKey::encode(databaseId, objectStoreId, 0, 0);
     const Vector<char> stopKey = IndexMetaDataKey::encode(databaseId, objectStoreId + 1, 0, 0);
 
@@ -916,6 +928,7 @@
 
 bool IDBLevelDBBackingStore::createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::createIndex");
     ASSERT(m_currentTransaction);
     indexId = getNewIndexId(m_currentTransaction.get(), databaseId, objectStoreId);
     if (indexId < 0)
@@ -955,6 +968,7 @@
 
 void IDBLevelDBBackingStore::deleteIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::deleteIndex");
     ASSERT(m_currentTransaction);
 
     const Vector<char> indexMetaDataStart = IndexMetaDataKey::encode(databaseId, objectStoreId, indexId, 0);
@@ -976,6 +990,7 @@
 
 bool IDBLevelDBBackingStore::putIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, const ObjectStoreRecordIdentifier* recordIdentifier)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::putIndexDataForRecord");
     ASSERT(key.isValid());
     ASSERT(indexId >= MinimumIndexId);
     const LevelDBRecordIdentifier* levelDBRecordIdentifier = static_cast<const LevelDBRecordIdentifier*>(recordIdentifier);
@@ -1035,12 +1050,13 @@
     return decodeInt(data.begin(), data.end()) == version;
 }
 
-static bool findKeyInIndex(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, Vector<char>& foundEncodedPrimaryKey)
+bool IDBLevelDBBackingStore::findKeyInIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, Vector<char>& foundEncodedPrimaryKey)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::findKeyInIndex");
     ASSERT(foundEncodedPrimaryKey.isEmpty());
 
     const Vector<char> leveldbKey = IndexDataKey::encode(databaseId, objectStoreId, indexId, key);
-    OwnPtr<LevelDBIterator> it = transaction->createIterator();
+    OwnPtr<LevelDBIterator> it = m_currentTransaction->createIterator();
     it->seek(leveldbKey);
 
     for (;;) {
@@ -1055,9 +1071,9 @@
             return false;
         foundEncodedPrimaryKey.append(p, it->value().end() - p);
 
-        if (!versionExists(transaction, databaseId, objectStoreId, version, foundEncodedPrimaryKey)) {
+        if (!versionExists(m_currentTransaction.get(), databaseId, objectStoreId, version, foundEncodedPrimaryKey)) {
             // Delete stale index data entry and continue.
-            transaction->remove(it->key());
+            m_currentTransaction->remove(it->key());
             it->next();
             continue;
         }
@@ -1068,10 +1084,11 @@
 
 PassRefPtr<IDBKey> IDBLevelDBBackingStore::getPrimaryKeyViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::getPrimaryKeyViaIndex");
     ASSERT(m_currentTransaction);
 
     Vector<char> foundEncodedPrimaryKey;
-    if (findKeyInIndex(m_currentTransaction.get(), databaseId, objectStoreId, indexId, key, foundEncodedPrimaryKey)) {
+    if (findKeyInIndex(databaseId, objectStoreId, indexId, key, foundEncodedPrimaryKey)) {
         RefPtr<IDBKey> primaryKey;
         decodeIDBKey(foundEncodedPrimaryKey.begin(), foundEncodedPrimaryKey.end(), primaryKey);
         return primaryKey.release();
@@ -1082,10 +1099,11 @@
 
 bool IDBLevelDBBackingStore::keyExistsInIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::keyExistsInIndex");
     ASSERT(m_currentTransaction);
 
     Vector<char> foundEncodedPrimaryKey;
-    if (!findKeyInIndex(m_currentTransaction.get(), databaseId, objectStoreId, indexId, indexKey, foundEncodedPrimaryKey))
+    if (!findKeyInIndex(databaseId, objectStoreId, indexId, indexKey, foundEncodedPrimaryKey))
         return false;
 
     decodeIDBKey(foundEncodedPrimaryKey.begin(), foundEncodedPrimaryKey.end(), foundPrimaryKey);
@@ -1518,6 +1536,7 @@
 
 PassRefPtr<IDBBackingStore::Cursor> IDBLevelDBBackingStore::openObjectStoreCursor(int64_t databaseId, int64_t objectStoreId, const IDBKeyRange* range, IDBCursor::Direction direction)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::openObjectStoreCursor");
     ASSERT(m_currentTransaction);
     CursorOptions cursorOptions;
 
@@ -1572,6 +1591,7 @@
 
 PassRefPtr<IDBBackingStore::Cursor> IDBLevelDBBackingStore::openIndexKeyCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange* range, IDBCursor::Direction direction)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::openIndexKeyCursor");
     ASSERT(m_currentTransaction);
     CursorOptions cursorOptions;
     bool lowerBound = range && range->lower();
@@ -1620,6 +1640,7 @@
 
 PassRefPtr<IDBBackingStore::Cursor> IDBLevelDBBackingStore::openIndexCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange* range, IDBCursor::Direction direction)
 {
+    IDB_TRACE("IDBLevelDBBackingStore::openIndexCursor");
     ASSERT(m_currentTransaction);
     CursorOptions cursorOptions;
     bool lowerBound = range && range->lower();
@@ -1689,6 +1710,7 @@
 
 bool IDBLevelDBBackingStore::Transaction::commit()
 {
+    IDB_TRACE("IDBLevelDBBackingStore::Transaction::commit");
     ASSERT(m_backingStore->m_currentTransaction);
     bool result = m_backingStore->m_currentTransaction->commit();
     m_backingStore->m_currentTransaction.clear();
@@ -1697,6 +1719,7 @@
 
 void IDBLevelDBBackingStore::Transaction::rollback()
 {
+    IDB_TRACE("IDBLevelDBBackingStore::Transaction::rollback");
     ASSERT(m_backingStore->m_currentTransaction);
     m_backingStore->m_currentTransaction->rollback();
     m_backingStore->m_currentTransaction.clear();

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.h (125626 => 125627)


--- trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.h	2012-08-15 00:56:02 UTC (rev 125626)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.h	2012-08-15 01:18:25 UTC (rev 125627)
@@ -85,6 +85,8 @@
     IDBLevelDBBackingStore(const String& identifier, IDBFactoryBackendImpl*, PassOwnPtr<LevelDBDatabase>);
 
 private:
+    bool findKeyInIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, Vector<char>& foundEncodedPrimaryKey);
+
     String m_identifier;
     RefPtr<IDBFactoryBackendImpl> m_factory;
     OwnPtr<LevelDBDatabase> m_db;

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp (125626 => 125627)


--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp	2012-08-15 00:56:02 UTC (rev 125626)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp	2012-08-15 01:18:25 UTC (rev 125627)
@@ -212,7 +212,7 @@
 
     bool addingKeyAllowed(IDBBackingStore& backingStore,
                           int64_t databaseId, int64_t objectStoreId, int64_t indexId,
-                          const IDBKey* indexKey, const IDBKey* primaryKey)
+                          const IDBKey* indexKey, const IDBKey* primaryKey) const
     {
         if (!m_indexMetadata.unique)
             return true;

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp (125626 => 125627)


--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp	2012-08-15 00:56:02 UTC (rev 125626)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp	2012-08-15 01:18:25 UTC (rev 125627)
@@ -262,6 +262,7 @@
 
 void IDBTransaction::onAbort()
 {
+    IDB_TRACE("IDBTransaction::onAbort");
     ASSERT(m_state != Finished);
 
     if (m_state != Finishing) {
@@ -294,6 +295,7 @@
 
 void IDBTransaction::onComplete()
 {
+    IDB_TRACE("IDBTransaction::onComplete");
     ASSERT(m_state != Finished);
     m_state = Finishing;
     m_objectStoreCleanupMap.clear();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to