Title: [128136] trunk/Source/WebCore
- Revision
- 128136
- Author
- [email protected]
- Date
- 2012-09-10 17:50:33 -0700 (Mon, 10 Sep 2012)
Log Message
IndexedDB: IDBFactory.deleteDatabase() is slow
https://bugs.webkit.org/show_bug.cgi?id=96036
Reviewed by Tony Chang.
The deleteDatabase() operation is implemented by creating a LevelDBTansaction to accumulate
the records to delete, then committing it. The transaction is a tree of key/operation pairs.
As each (key, delete) entry is added to the tree compares need to be made, potentially
requiring full key decodes. Since this temporary transaction is never read from, this is
overkill.
Add a new "write only" transaction type that simply wraps a write batch, which provides
transaction integrity but avoids the insertion overhead and has a minimal interface.
No new tests - no functional changes, only perf improvement.
* Modules/indexeddb/IDBLevelDBBackingStore.cpp:
(WebCore::IDBLevelDBBackingStore::deleteDatabase): Use new write-only transaction type.
* platform/leveldb/LevelDBTransaction.cpp:
(WebCore::LevelDBWriteOnlyTransaction::create):
(WebCore):
(WebCore::LevelDBWriteOnlyTransaction::LevelDBWriteOnlyTransaction):
(WebCore::LevelDBWriteOnlyTransaction::~LevelDBWriteOnlyTransaction):
(WebCore::LevelDBWriteOnlyTransaction::remove):
(WebCore::LevelDBWriteOnlyTransaction::commit):
* platform/leveldb/LevelDBTransaction.h:
(WebCore):
(LevelDBWriteOnlyTransaction):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (128135 => 128136)
--- trunk/Source/WebCore/ChangeLog 2012-09-11 00:41:13 UTC (rev 128135)
+++ trunk/Source/WebCore/ChangeLog 2012-09-11 00:50:33 UTC (rev 128136)
@@ -1,3 +1,34 @@
+2012-09-10 Joshua Bell <[email protected]>
+
+ IndexedDB: IDBFactory.deleteDatabase() is slow
+ https://bugs.webkit.org/show_bug.cgi?id=96036
+
+ Reviewed by Tony Chang.
+
+ The deleteDatabase() operation is implemented by creating a LevelDBTansaction to accumulate
+ the records to delete, then committing it. The transaction is a tree of key/operation pairs.
+ As each (key, delete) entry is added to the tree compares need to be made, potentially
+ requiring full key decodes. Since this temporary transaction is never read from, this is
+ overkill.
+
+ Add a new "write only" transaction type that simply wraps a write batch, which provides
+ transaction integrity but avoids the insertion overhead and has a minimal interface.
+
+ No new tests - no functional changes, only perf improvement.
+
+ * Modules/indexeddb/IDBLevelDBBackingStore.cpp:
+ (WebCore::IDBLevelDBBackingStore::deleteDatabase): Use new write-only transaction type.
+ * platform/leveldb/LevelDBTransaction.cpp:
+ (WebCore::LevelDBWriteOnlyTransaction::create):
+ (WebCore):
+ (WebCore::LevelDBWriteOnlyTransaction::LevelDBWriteOnlyTransaction):
+ (WebCore::LevelDBWriteOnlyTransaction::~LevelDBWriteOnlyTransaction):
+ (WebCore::LevelDBWriteOnlyTransaction::remove):
+ (WebCore::LevelDBWriteOnlyTransaction::commit):
+ * platform/leveldb/LevelDBTransaction.h:
+ (WebCore):
+ (LevelDBWriteOnlyTransaction):
+
2012-09-10 Adam Barth <[email protected]>
[V8] createFunctionOnlyCallback should be in V8Callback.h with the other callback functions
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp (128135 => 128136)
--- trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp 2012-09-11 00:41:13 UTC (rev 128135)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp 2012-09-11 00:50:33 UTC (rev 128136)
@@ -372,22 +372,19 @@
bool IDBLevelDBBackingStore::deleteDatabase(const String& name)
{
IDB_TRACE("IDBLevelDBBackingStore::deleteDatabase");
- RefPtr<LevelDBTransaction> transaction = LevelDBTransaction::create(m_db.get());
+ OwnPtr<LevelDBWriteOnlyTransaction> transaction = LevelDBWriteOnlyTransaction::create(m_db.get());
int64_t databaseId;
String version;
int64_t intVersion;
- if (!getIDBDatabaseMetaData(name, version, intVersion, databaseId)) {
- transaction->rollback();
+ if (!getIDBDatabaseMetaData(name, version, intVersion, databaseId))
return true;
- }
const Vector<char> startKey = DatabaseMetaDataKey::encode(databaseId, DatabaseMetaDataKey::OriginName);
const Vector<char> stopKey = DatabaseMetaDataKey::encode(databaseId + 1, DatabaseMetaDataKey::OriginName);
- if (!deleteRange(transaction.get(), startKey, stopKey)) {
- transaction->rollback();
- return false;
- }
+ OwnPtr<LevelDBIterator> it = m_db->createIterator();
+ for (it->seek(startKey); it->isValid() && compareKeys(it->key(), stopKey) < 0; it->next())
+ transaction->remove(it->key());
const Vector<char> key = DatabaseNameKey::encode(m_identifier, name);
transaction->remove(key);
Modified: trunk/Source/WebCore/platform/leveldb/LevelDBTransaction.cpp (128135 => 128136)
--- trunk/Source/WebCore/platform/leveldb/LevelDBTransaction.cpp 2012-09-11 00:41:13 UTC (rev 128135)
+++ trunk/Source/WebCore/platform/leveldb/LevelDBTransaction.cpp 2012-09-11 00:50:33 UTC (rev 128136)
@@ -485,6 +485,41 @@
}
}
+PassOwnPtr<LevelDBWriteOnlyTransaction> LevelDBWriteOnlyTransaction::create(LevelDBDatabase* db)
+{
+ return adoptPtr(new LevelDBWriteOnlyTransaction(db));
+}
+
+LevelDBWriteOnlyTransaction::LevelDBWriteOnlyTransaction(LevelDBDatabase* db)
+ : m_db(db)
+ , m_writeBatch(LevelDBWriteBatch::create())
+ , m_finished(false)
+{
+}
+
+LevelDBWriteOnlyTransaction::~LevelDBWriteOnlyTransaction()
+{
+ m_writeBatch->clear();
+}
+
+void LevelDBWriteOnlyTransaction::remove(const LevelDBSlice& key)
+{
+ ASSERT(!m_finished);
+ m_writeBatch->remove(key);
+}
+
+bool LevelDBWriteOnlyTransaction::commit()
+{
+ ASSERT(!m_finished);
+
+ if (!m_db->write(*m_writeBatch))
+ return false;
+
+ m_finished = true;
+ m_writeBatch->clear();
+ return true;
+}
+
} // namespace WebCore
#endif // USE(LEVELDB)
Modified: trunk/Source/WebCore/platform/leveldb/LevelDBTransaction.h (128135 => 128136)
--- trunk/Source/WebCore/platform/leveldb/LevelDBTransaction.h 2012-09-11 00:41:13 UTC (rev 128135)
+++ trunk/Source/WebCore/platform/leveldb/LevelDBTransaction.h 2012-09-11 00:50:33 UTC (rev 128136)
@@ -43,6 +43,7 @@
namespace WebCore {
class LevelDBDatabase;
+class LevelDBWriteBatch;
using WTF::AVLTree;
@@ -169,6 +170,22 @@
HashSet<TransactionIterator*> m_iterators;
};
+class LevelDBWriteOnlyTransaction {
+public:
+ static PassOwnPtr<LevelDBWriteOnlyTransaction> create(LevelDBDatabase*);
+
+ ~LevelDBWriteOnlyTransaction();
+ void remove(const LevelDBSlice& key);
+ bool commit();
+
+private:
+ LevelDBWriteOnlyTransaction(LevelDBDatabase*);
+
+ LevelDBDatabase* m_db;
+ OwnPtr<LevelDBWriteBatch> m_writeBatch;
+ bool m_finished;
+};
+
}
#endif // USE(LEVELDB)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes