pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/WebKit/WebKit-http/commit/37a90a973bb2dbfe5f55e8df2db2ac5a06423a87

t" href="https://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> IndexedDB: speed up index records deletion · WebKit/WebKit-http@37a90a9 · GitHub
Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 37a90a9

Browse files
author
sihui_liu@apple.com
committed
IndexedDB: speed up index records deletion
https://bugs.webkit.org/show_bug.cgi?id=206196 PerformanceTests: Reviewed by Brady Eidson. * IndexedDB/basic/index-cursor-delete-2.html: Added. Source/WebCore: <rdar://problem/53596307> Reviewed by Brady Eidson. This patch does a few things to accelerate deletion for index records: 1. make indexID unique in database instead of objectStore 2. create an index on IndexRecords table 3. optimize some SQLite statements to take advantage of 1 and 2 Test: IndexedDB.IDBObjectStoreInfoUpgradeToV2 Make test PerformanceTests/IndexedDB/basic/index-cursor-delete-2.html 7.5x faster. * Modules/indexeddb/IDBDatabase.h: * Modules/indexeddb/IDBObjectStore.cpp: (WebCore::IDBObjectStore::createIndex): * Modules/indexeddb/server/MemoryIDBBackingStore.cpp: (WebCore::IDBServer::MemoryIDBBackingStore::getOrEstablishDatabaseInfo): (WebCore::IDBServer::MemoryIDBBackingStore::createIndex): * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp: (WebCore::IDBServer::createV1ObjectStoreInfoSchema): (WebCore::IDBServer::createV2ObjectStoreInfoSchema): (WebCore::IDBServer::SQLiteIDBBackingStore::ensureValidIndexRecordsRecordIndex): (WebCore::IDBServer::SQLiteIDBBackingStore::createAndPopulateInitialDatabaseInfo): (WebCore::IDBServer::SQLiteIDBBackingStore::ensureValidObjectStoreInfoTable): (WebCore::IDBServer::SQLiteIDBBackingStore::extractExistingDatabaseInfo): (WebCore::IDBServer::SQLiteIDBBackingStore::getOrEstablishDatabaseInfo): (WebCore::IDBServer::SQLiteIDBBackingStore::createObjectStore): (WebCore::IDBServer::SQLiteIDBBackingStore::createIndex): (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedHasIndexRecord): (WebCore::IDBServer::SQLiteIDBBackingStore::deleteIndex): (WebCore::IDBServer::SQLiteIDBBackingStore::deleteRecord): (WebCore::IDBServer::SQLiteIDBBackingStore::updateAllIndexesForAddRecord): (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedGetIndexRecordForOneKey): (WebCore::IDBServer::SQLiteIDBBackingStore::deleteOneIndexRecord): Deleted. * Modules/indexeddb/server/SQLiteIDBBackingStore.h: * Modules/indexeddb/server/SQLiteIDBCursor.cpp: (WebCore::IDBServer::buildIndexStatement): (WebCore::IDBServer::SQLiteIDBCursor::bindArguments): * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::createIndex): * Modules/indexeddb/shared/IDBDatabaseInfo.cpp: (WebCore::IDBDatabaseInfo::IDBDatabaseInfo): (WebCore::IDBDatabaseInfo::setMaxIndexID): * Modules/indexeddb/shared/IDBDatabaseInfo.h: (WebCore::IDBDatabaseInfo::generateNextIndexID): (WebCore::IDBDatabaseInfo::encode const): (WebCore::IDBDatabaseInfo::decode): * Modules/indexeddb/shared/IDBObjectStoreInfo.cpp: (WebCore::IDBObjectStoreInfo::createNewIndex): (WebCore::IDBObjectStoreInfo::addExistingIndex): (WebCore::IDBObjectStoreInfo::isolatedCopy const): * Modules/indexeddb/shared/IDBObjectStoreInfo.h: (WebCore::IDBObjectStoreInfo::autoIncrement const): (WebCore::IDBObjectStoreInfo::encode const): (WebCore::IDBObjectStoreInfo::decode): (WebCore::IDBObjectStoreInfo::maxIndexID const): Deleted. Tools: Reviewed by Brady Eidson. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKitCocoa/IDBObjectStoreInfoUpgrade.sqlite3: Added. * TestWebKitAPI/Tests/WebKitCocoa/IDBObjectStoreInfoUpgradeToV2.html: Added. * TestWebKitAPI/Tests/WebKitCocoa/IDBObjectStoreInfoUpgradeToV2.mm: Added. (-[IDBObjectStoreInfoUpgradeToV2MessageHandler userContentController:didReceiveScriptMessage:]): (TEST): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@255318 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent d5373f2 commit 37a90a9

19 files changed

Lines changed: 529 additions & 96 deletions

PerformanceTests/ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2020-01-28 Sihui Liu <sihui_liu@apple.com>
2+
3+
IndexedDB: speed up index records deletion
4+
https://bugs.webkit.org/show_bug.cgi?id=206196
5+
6+
Reviewed by Brady Eidson.
7+
8+
* IndexedDB/basic/index-cursor-delete-2.html: Added.
9+
110
2020-01-08 Sihui Liu <sihui_liu@apple.com>
211

312
REGRESSION (r242911?): High Sierra Release WK2 Perf bot timing out while running IndexedDB/large-number-of-inserts.html
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<script src="../../resources/runner.js"></script>
5+
<script>
6+
7+
const numberOfIterations = 20;
8+
const numberOfItems = 10000;
9+
const numberOfItemsToDelete = 5000;
10+
11+
// Delete database(s) for the test ahead of time.
12+
var databaseName = "index-cursor-delete-DB-2";
13+
indexedDB.deleteDatabase(databaseName).onsuccess = function() {
14+
startIteration();
15+
}
16+
17+
var testGenerator = null;
18+
var db = null;
19+
var transaction = null;
20+
21+
PerfTestRunner.prepareToMeasureValuesAsync({
22+
customIterationCount: numberOfIterations,
23+
unit: 'ms',
24+
done: function () {
25+
transaction = null;
26+
db = null;
27+
testGenerator = null;
28+
PerfTestRunner.gc();
29+
}
30+
});
31+
32+
function startIteration()
33+
{
34+
testGenerator = runIteration();
35+
nextStep();
36+
}
37+
38+
function nextStep()
39+
{
40+
testGenerator.next();
41+
}
42+
43+
function *runIteration()
44+
{
45+
var openRequest = indexedDB.open(databaseName);
46+
openRequest.onupgradeneeded = function(event) {
47+
db = event.target.result;
48+
var objectStore = db.createObjectStore('store', { keyPath: 'uniqueIndexKey' });
49+
objectStore.createIndex('uniqueIndex', 'uniqueIndexKey', { unique: true });
50+
objectStore.createIndex('index', 'indexKey');
51+
}
52+
openRequest.onsuccess = nextStep;
53+
54+
yield;
55+
56+
// Store items for deletion.
57+
transaction = db.transaction('store', 'readwrite');
58+
var objectStore = transaction.objectStore('store');
59+
for (var i = 0; i < numberOfItems; ++i)
60+
objectStore.put({ value: 'value', uniqueIndexKey: "uniqueIndexKey" + i, indexKey: "index" + (i%2) });
61+
62+
transaction.oncomplete = function(event) {
63+
nextStep();
64+
}
65+
66+
yield;
67+
68+
var startTime = PerfTestRunner.now();
69+
70+
var index = db.transaction('store', 'readwrite').objectStore('store').index('index');
71+
var completedDeletes = 0;
72+
index.openCursor(IDBKeyRange.only('index1')).onsuccess = function(event) {
73+
var cursor = event.target.result;
74+
if(cursor) {
75+
cursor.delete().onsuccess = function(event) {
76+
if (++completedDeletes == numberOfItemsToDelete)
77+
nextStep();
78+
}
79+
80+
cursor.continue();
81+
}
82+
}
83+
84+
yield;
85+
86+
if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime))
87+
return;
88+
89+
setTimeout(startIteration, 0);
90+
}
91+
</script>
92+
</body>
93+
</html>

Source/WebCore/ChangeLog

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
1+
2020-01-28 Sihui Liu <sihui_liu@apple.com>
2+
3+
IndexedDB: speed up index records deletion
4+
https://bugs.webkit.org/show_bug.cgi?id=206196
5+
<rdar://problem/53596307>
6+
7+
Reviewed by Brady Eidson.
8+
9+
This patch does a few things to accelerate deletion for index records:
10+
1. make indexID unique in database instead of objectStore
11+
2. create an index on IndexRecords table
12+
3. optimize some SQLite statements to take advantage of 1 and 2
13+
14+
Test: IndexedDB.IDBObjectStoreInfoUpgradeToV2
15+
16+
Make test PerformanceTests/IndexedDB/basic/index-cursor-delete-2.html 7.5x faster.
17+
18+
* Modules/indexeddb/IDBDatabase.h:
19+
* Modules/indexeddb/IDBObjectStore.cpp:
20+
(WebCore::IDBObjectStore::createIndex):
21+
* Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
22+
(WebCore::IDBServer::MemoryIDBBackingStore::getOrEstablishDatabaseInfo):
23+
(WebCore::IDBServer::MemoryIDBBackingStore::createIndex):
24+
* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
25+
(WebCore::IDBServer::createV1ObjectStoreInfoSchema):
26+
(WebCore::IDBServer::createV2ObjectStoreInfoSchema):
27+
(WebCore::IDBServer::SQLiteIDBBackingStore::ensureValidIndexRecordsRecordIndex):
28+
(WebCore::IDBServer::SQLiteIDBBackingStore::createAndPopulateInitialDatabaseInfo):
29+
(WebCore::IDBServer::SQLiteIDBBackingStore::ensureValidObjectStoreInfoTable):
30+
(WebCore::IDBServer::SQLiteIDBBackingStore::extractExistingDatabaseInfo):
31+
(WebCore::IDBServer::SQLiteIDBBackingStore::getOrEstablishDatabaseInfo):
32+
(WebCore::IDBServer::SQLiteIDBBackingStore::createObjectStore):
33+
(WebCore::IDBServer::SQLiteIDBBackingStore::createIndex):
34+
(WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedHasIndexRecord):
35+
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteIndex):
36+
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteRecord):
37+
(WebCore::IDBServer::SQLiteIDBBackingStore::updateAllIndexesForAddRecord):
38+
(WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedGetIndexRecordForOneKey):
39+
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteOneIndexRecord): Deleted.
40+
* Modules/indexeddb/server/SQLiteIDBBackingStore.h:
41+
* Modules/indexeddb/server/SQLiteIDBCursor.cpp:
42+
(WebCore::IDBServer::buildIndexStatement):
43+
(WebCore::IDBServer::SQLiteIDBCursor::bindArguments):
44+
* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
45+
(WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore):
46+
(WebCore::IDBServer::UniqueIDBDatabase::createIndex):
47+
* Modules/indexeddb/shared/IDBDatabaseInfo.cpp:
48+
(WebCore::IDBDatabaseInfo::IDBDatabaseInfo):
49+
(WebCore::IDBDatabaseInfo::setMaxIndexID):
50+
* Modules/indexeddb/shared/IDBDatabaseInfo.h:
51+
(WebCore::IDBDatabaseInfo::generateNextIndexID):
52+
(WebCore::IDBDatabaseInfo::encode const):
53+
(WebCore::IDBDatabaseInfo::decode):
54+
* Modules/indexeddb/shared/IDBObjectStoreInfo.cpp:
55+
(WebCore::IDBObjectStoreInfo::createNewIndex):
56+
(WebCore::IDBObjectStoreInfo::addExistingIndex):
57+
(WebCore::IDBObjectStoreInfo::isolatedCopy const):
58+
* Modules/indexeddb/shared/IDBObjectStoreInfo.h:
59+
(WebCore::IDBObjectStoreInfo::autoIncrement const):
60+
(WebCore::IDBObjectStoreInfo::encode const):
61+
(WebCore::IDBObjectStoreInfo::decode):
62+
(WebCore::IDBObjectStoreInfo::maxIndexID const): Deleted.
63+
164
2020-01-28 Justin Fan <justin_fan@apple.com>
265

366
[WebGL2] Implement sub-source texImage2D and texSubImage2D

Source/WebCore/Modules/indexeddb/IDBDatabase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class IDBDatabase final : public ThreadSafeRefCounted<IDBDatabase>, public Event
8484
const char* activeDOMObjectName() const final;
8585
void stop() final;
8686

87-
const IDBDatabaseInfo& info() const { return m_info; }
87+
IDBDatabaseInfo& info() { return m_info; }
8888
uint64_t databaseConnectionIdentifier() const { return m_databaseConnectionIdentifier; }
8989

9090
Ref<IDBTransaction> startVersionChangeTransaction(const IDBTransactionInfo&, IDBOpenDBRequest&);

Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ ExceptionOr<Ref<IDBIndex>> IDBObjectStore::createIndex(JSGlobalObject&, const St
475475
return Exception { InvalidAccessError, "Failed to execute 'createIndex' on 'IDBObjectStore': The keyPath argument was an array and the multiEntry option is true."_s };
476476

477477
// Install the new Index into the ObjectStore's info.
478-
IDBIndexInfo info = m_info.createNewIndex(name, WTFMove(keyPath), parameters.unique, parameters.multiEntry);
478+
IDBIndexInfo info = m_info.createNewIndex(m_transaction.database().info().generateNextIndexID(), name, WTFMove(keyPath), parameters.unique, parameters.multiEntry);
479479
m_transaction.database().didCreateIndexInfo(info);
480480

481481
// Create the actual IDBObjectStore from the transaction, which also schedules the operation server side.

Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ MemoryIDBBackingStore::~MemoryIDBBackingStore() = default;
5757
IDBError MemoryIDBBackingStore::getOrEstablishDatabaseInfo(IDBDatabaseInfo& info)
5858
{
5959
if (!m_databaseInfo)
60-
m_databaseInfo = makeUnique<IDBDatabaseInfo>(m_identifier.databaseName(), 0);
60+
m_databaseInfo = makeUnique<IDBDatabaseInfo>(m_identifier.databaseName(), 0, 0);
6161

6262
info = *m_databaseInfo;
6363
return IDBError { };
@@ -236,8 +236,10 @@ IDBError MemoryIDBBackingStore::createIndex(const IDBResourceIdentifier& transac
236236
return IDBError { ConstraintError };
237237

238238
auto error = objectStore->createIndex(*rawTransaction, info);
239-
if (error.isNull())
239+
if (error.isNull()) {
240240
objectStoreInfo->addExistingIndex(info);
241+
m_databaseInfo->setMaxIndexID(info.identifier());
242+
}
241243

242244
return error;
243245
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy