IDB: Add implementation for getAllRecords()
Categories
(Core :: Storage: IndexedDB, enhancement, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox153 | --- | fixed |
People
(Reporter: janv, Assigned: abienner)
References
(Blocks 1 open bug)
Details
(Keywords: web-feature, Whiteboard: [platform-feature][webcompat:risk-moderate], [wptsync upstream])
User Story
web-feature: getallrecords
Attachments
(8 files, 1 obsolete file)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
138.37 KB,
image/png
|
Details | |
|
137.88 KB,
image/png
|
Details | |
|
137.26 KB,
image/png
|
Details | |
|
10.38 KB,
text/html
|
Details |
| Reporter | ||
Updated•1 year ago
|
Updated•7 months ago
|
Updated•6 months ago
|
Updated•6 months ago
|
Updated•3 months ago
|
| Assignee | ||
Updated•2 months ago
|
| Assignee | ||
Comment 1•2 months ago
|
||
Updated•2 months ago
|
| Assignee | ||
Comment 2•2 months ago
|
||
Updated•2 months ago
|
| Assignee | ||
Comment 3•2 months ago
|
||
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
| Assignee | ||
Comment 4•2 months ago
|
||
Refactor code a bit to ease reuse between IDBObjectStore and IDBIndex
| Assignee | ||
Comment 5•1 month ago
|
||
| Assignee | ||
Comment 6•1 month ago
•
|
||
I'm following up of the conversion we had on https://phabricator.services.mozilla.com/D295592#10281123 so I can add attachments.
I'm summarizing here my findings regarding the performance analysis of this new function.
First, what is a good dataset for benchmark?
I used dfindexeddb (https://github.com/google/dfindexeddb) to analyze all the IndexedDB I had locally, on my regular profile, which probably represents enough of the average user.
For keys, I had (roughly):
- String: 53%
- Numbers: 27%
- Arrays: 20%
On data types stored, almost everything is an object.
Since there is the opportunity to do some lazy loading, I wanted to assess the impact in terms of performance.
I think there might be some usage where keys are not always accessed, for instance when doing pagination, as described here: https://patrickbrosset.com/articles/2024-11-19-even-faster-indexeddb-reads-with-getallrecords/ (in this case only one key is accessed for each getAllRequest request, to create the next range request).
When key are being accessed, it makes sense to only access one on object store, since primary key and key are the same thing.
So I benchmarked acces value only and key + value. And access all fields too, even if I stated above I don't think there is a real usecase for that on IDBObjectStore.
My benchmark focuses on IDBObjectStore, as I think it is the main usecase. Could do the same thing for IDBIndex if someone thinks this is needed.
To perform lazy loading, there are two options:
- Use [Cached] attribute in .webidl file
- Pros: less code
- Cons: can't do aliasing (i.e. have IDBObjectStore's primary key and key points to the same object, since they are the same thing)
- Use caching at the C++ level, like we have for IDBCursor currently: https://searchfox.org/firefox-main/source/dom/indexedDB/IDBCursor.cpp#246
- Pros: consistent with IDBCursor, can do aliasing for key/primary key
- Cons: more code
I run some experiment using the attached perf_object.html file, with the 3 approaches:
- No caching at all: IDB Read Performance Tests — ob-os NoCache.png
- [Cached] attribute in webidl: IDB Read Performance Tests — ob-os [Cached].png
- Caching at C++ level (using bool bitfields): IDB Read Performance Tests — ob-os BoolCached.png
Bottom line:
- Caching adds a bit of overhead in the cases where we access key(s) + value
- The two lazy loading approaches gives similar results:
- [Cached] seems to be slightly more efficient, probably because it avoids hitting the C++ object.
- BoolCached (IDBCursor approach) is more efficient for the case when all fields are accessed and the key is big. This is expected thanks to the primary/key aliasing, since the key's deserialization happens only once
Note: apart from performance, having lazy loading also allows web apps to be more responsive, if records aren't accessed right away.
| Assignee | ||
Comment 7•1 month ago
|
||
| Assignee | ||
Comment 8•1 month ago
|
||
| Assignee | ||
Comment 9•1 month ago
|
||
| Assignee | ||
Comment 10•1 month ago
|
||
Updated•29 days ago
|
Updated•5 days ago
|
Updated•5 days ago
|
Updated•4 days ago
|
Comment 12•2 days ago
|
||
Comment 13•2 days ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/825f0771314a
https://hg.mozilla.org/mozilla-central/rev/76a7c3ec5732
https://hg.mozilla.org/mozilla-central/rev/621cd3bee7f0
https://hg.mozilla.org/mozilla-central/rev/c256727f029f
| Reporter | ||
Updated•2 days ago
|
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/60243 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Description
•