-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define size of all storage actions #110
Comments
This seems desirable and has indeed come up before. Specifically, in terms of allowing structured serialized storage of data on things like ServiceWorker registrations and related data (ex: Notification.data) where it would be desirable to place an upper bound on storage but is an interop nightmare without this issue addressed. I believe this would require the serialization steps for It seems like the most complex issues are;
|
Thank you very much for opening a specific issue for this topic! Reiterating here for clarity -- Chrome is supportive of this effort to come up with an abstract cost model for storage. We'd be willing to take on the (quite non-trivial) implementation costs if the model gains cross-browser acceptance. I also really like that @asutherland brought up some of the complex issues early on. I'd be tempted to follow the solutions of other systems I'm aware of.
On a brighter note, the zstd benchmarks suggest that the algorithms we'd consider have ratios within 2x of each other (and below 3x of uncompressed) for "typical" data. I claim this is well within the precision margin for the cost model we'd be building up here. Along the same lines, I hope that we can avoid having apps play games (like manual compression) by being reasonably generous with quota. Ideally, apps without bugs should not run into quota problems. |
I found some notes from when I tried to sketch a storage cost model for IndexedDB. This was in 2018, and I knew a lot less about the implementation back then. So, the numbers are probably bad, but at least it's a list of things to consider. Object cost:
I might have missed some other object. The idea is to assign a cost based on a straightforward representation for each clonable. The cost doesn't have to be exact, because we expect implementations to have their own overhead. IndexedDB transaction costs (get refunded when the transaction completes):
This isn't a complete list. I hope it's a good starting point if someone is itching to start an explainer 😄 |
@pwnall Your simplifying proposal in #110 (comment) sounds good to me. Also, it's very consistent with reality, as Mozilla's Servo project is an example of bringing up a browser from scratch-ish and they've found implementing IndexedDB non-trivial, so further complicating the standard and raising the bar to building a compliant browser engine would not be a win for the web. |
See also: whatwg/html#4914. |
storagemanager-estimate and estimate-indexeddb are more or less the same tests, the latter having been ported from the former to use `async`/`await`. The former probably should have been deleted when the latter was introduced. Since some of the tests are related to IndexedDB and some are not, this change keeps the IndexedDB tests in the file called `estimate-indexeddb` and keeps the basic tests in `storagemanager-estimate` (with minor updates). One wrinkle from the Chromium side is that the behavior of `storageManager.estimate()` is not actually specced, and as the Chromium implementation uses LevelDB, which behaves in mysterious ways, adding things to the database does NOT always increase the reported usage size. Both of these tests operate on large things, which typically do increase usage, however we noticed that for one reason or another, the test that adds an *uninitialized* ArrayBuffer starts failing on Windows if durability is set to relaxed. There are other ways to make the test fail as well: using a shorter name for the database, or putting small values, does not reliably increase the reported usage. This is all fine in the sense that it isn't defined behavior, but it does suggest that working in this area or on tests of this ilk is a bit of a minefield. These tests probably should not exist as WPT, at least not until quota behavior is specced (see whatwg/storage#110). But it would also be sort of a shame to delete WPT that are passing, so I've left them in place for now. Bug: 1489517 Change-Id: I6619f504ce92e428054691ac6bf54a0e14e3ce5f
storagemanager-estimate and estimate-indexeddb are more or less the same tests, the latter having been ported from the former to use `async`/`await`. The former probably should have been deleted when the latter was introduced. Since some of the tests are related to IndexedDB and some are not, this change keeps the IndexedDB tests in the file called `estimate-indexeddb` and keeps the basic tests in `storagemanager-estimate` (with minor updates). One wrinkle from the Chromium side is that the behavior of `storageManager.estimate()` is not actually specced, and as the Chromium implementation uses LevelDB, which behaves in mysterious ways, adding things to the database does NOT always increase the reported usage size. Both of these tests operate on large things, which typically do increase usage, however we noticed that for one reason or another, the test that adds an *uninitialized* ArrayBuffer starts failing on Windows if durability is set to relaxed. There are other ways to make the test fail as well: using a shorter name for the database, or putting small values, does not reliably increase the reported usage. This is all fine in the sense that it isn't defined behavior, but it does suggest that working in this area or on tests of this ilk is a bit of a minefield. These tests probably should not exist as WPT, at least not until quota behavior is specced (see whatwg/storage#110). But it would also be sort of a shame to delete WPT that are passing, so I've left them in place for now. Bug: 1489517 Change-Id: I6619f504ce92e428054691ac6bf54a0e14e3ce5f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4968659 Commit-Queue: Evan Stade <[email protected]> Reviewed-by: Ayu Ishii <[email protected]> Cr-Commit-Position: refs/heads/main@{#1214324}
storagemanager-estimate and estimate-indexeddb are more or less the same tests, the latter having been ported from the former to use `async`/`await`. The former probably should have been deleted when the latter was introduced. Since some of the tests are related to IndexedDB and some are not, this change keeps the IndexedDB tests in the file called `estimate-indexeddb` and keeps the basic tests in `storagemanager-estimate` (with minor updates). One wrinkle from the Chromium side is that the behavior of `storageManager.estimate()` is not actually specced, and as the Chromium implementation uses LevelDB, which behaves in mysterious ways, adding things to the database does NOT always increase the reported usage size. Both of these tests operate on large things, which typically do increase usage, however we noticed that for one reason or another, the test that adds an *uninitialized* ArrayBuffer starts failing on Windows if durability is set to relaxed. There are other ways to make the test fail as well: using a shorter name for the database, or putting small values, does not reliably increase the reported usage. This is all fine in the sense that it isn't defined behavior, but it does suggest that working in this area or on tests of this ilk is a bit of a minefield. These tests probably should not exist as WPT, at least not until quota behavior is specced (see whatwg/storage#110). But it would also be sort of a shame to delete WPT that are passing, so I've left them in place for now. Bug: 1489517 Change-Id: I6619f504ce92e428054691ac6bf54a0e14e3ce5f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4968659 Commit-Queue: Evan Stade <[email protected]> Reviewed-by: Ayu Ishii <[email protected]> Cr-Commit-Position: refs/heads/main@{#1214324}
storagemanager-estimate and estimate-indexeddb are more or less the same tests, the latter having been ported from the former to use `async`/`await`. The former probably should have been deleted when the latter was introduced. Since some of the tests are related to IndexedDB and some are not, this change keeps the IndexedDB tests in the file called `estimate-indexeddb` and keeps the basic tests in `storagemanager-estimate` (with minor updates). One wrinkle from the Chromium side is that the behavior of `storageManager.estimate()` is not actually specced, and as the Chromium implementation uses LevelDB, which behaves in mysterious ways, adding things to the database does NOT always increase the reported usage size. Both of these tests operate on large things, which typically do increase usage, however we noticed that for one reason or another, the test that adds an *uninitialized* ArrayBuffer starts failing on Windows if durability is set to relaxed. There are other ways to make the test fail as well: using a shorter name for the database, or putting small values, does not reliably increase the reported usage. This is all fine in the sense that it isn't defined behavior, but it does suggest that working in this area or on tests of this ilk is a bit of a minefield. These tests probably should not exist as WPT, at least not until quota behavior is specced (see whatwg/storage#110). But it would also be sort of a shame to delete WPT that are passing, so I've left them in place for now. Bug: 1489517 Change-Id: I6619f504ce92e428054691ac6bf54a0e14e3ce5f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4968659 Commit-Queue: Evan Stade <[email protected]> Reviewed-by: Ayu Ishii <[email protected]> Cr-Commit-Position: refs/heads/main@{#1214324}
Automatic update from web-platform-tests Deduplicate some WPT. storagemanager-estimate and estimate-indexeddb are more or less the same tests, the latter having been ported from the former to use `async`/`await`. The former probably should have been deleted when the latter was introduced. Since some of the tests are related to IndexedDB and some are not, this change keeps the IndexedDB tests in the file called `estimate-indexeddb` and keeps the basic tests in `storagemanager-estimate` (with minor updates). One wrinkle from the Chromium side is that the behavior of `storageManager.estimate()` is not actually specced, and as the Chromium implementation uses LevelDB, which behaves in mysterious ways, adding things to the database does NOT always increase the reported usage size. Both of these tests operate on large things, which typically do increase usage, however we noticed that for one reason or another, the test that adds an *uninitialized* ArrayBuffer starts failing on Windows if durability is set to relaxed. There are other ways to make the test fail as well: using a shorter name for the database, or putting small values, does not reliably increase the reported usage. This is all fine in the sense that it isn't defined behavior, but it does suggest that working in this area or on tests of this ilk is a bit of a minefield. These tests probably should not exist as WPT, at least not until quota behavior is specced (see whatwg/storage#110). But it would also be sort of a shame to delete WPT that are passing, so I've left them in place for now. Bug: 1489517 Change-Id: I6619f504ce92e428054691ac6bf54a0e14e3ce5f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4968659 Commit-Queue: Evan Stade <[email protected]> Reviewed-by: Ayu Ishii <[email protected]> Cr-Commit-Position: refs/heads/main@{#1214324} -- wpt-commits: 446b9bce1ca9a174c11c64f4faa077a9e9d22e72 wpt-pr: 42700
Automatic update from web-platform-tests Deduplicate some WPT. storagemanager-estimate and estimate-indexeddb are more or less the same tests, the latter having been ported from the former to use `async`/`await`. The former probably should have been deleted when the latter was introduced. Since some of the tests are related to IndexedDB and some are not, this change keeps the IndexedDB tests in the file called `estimate-indexeddb` and keeps the basic tests in `storagemanager-estimate` (with minor updates). One wrinkle from the Chromium side is that the behavior of `storageManager.estimate()` is not actually specced, and as the Chromium implementation uses LevelDB, which behaves in mysterious ways, adding things to the database does NOT always increase the reported usage size. Both of these tests operate on large things, which typically do increase usage, however we noticed that for one reason or another, the test that adds an *uninitialized* ArrayBuffer starts failing on Windows if durability is set to relaxed. There are other ways to make the test fail as well: using a shorter name for the database, or putting small values, does not reliably increase the reported usage. This is all fine in the sense that it isn't defined behavior, but it does suggest that working in this area or on tests of this ilk is a bit of a minefield. These tests probably should not exist as WPT, at least not until quota behavior is specced (see whatwg/storage#110). But it would also be sort of a shame to delete WPT that are passing, so I've left them in place for now. Bug: 1489517 Change-Id: I6619f504ce92e428054691ac6bf54a0e14e3ce5f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4968659 Commit-Queue: Evan Stade <[email protected]> Reviewed-by: Ayu Ishii <[email protected]> Cr-Commit-Position: refs/heads/main@{#1214324} -- wpt-commits: 446b9bce1ca9a174c11c64f4faa077a9e9d22e72 wpt-pr: 42700
Automatic update from web-platform-tests Deduplicate some WPT. storagemanager-estimate and estimate-indexeddb are more or less the same tests, the latter having been ported from the former to use `async`/`await`. The former probably should have been deleted when the latter was introduced. Since some of the tests are related to IndexedDB and some are not, this change keeps the IndexedDB tests in the file called `estimate-indexeddb` and keeps the basic tests in `storagemanager-estimate` (with minor updates). One wrinkle from the Chromium side is that the behavior of `storageManager.estimate()` is not actually specced, and as the Chromium implementation uses LevelDB, which behaves in mysterious ways, adding things to the database does NOT always increase the reported usage size. Both of these tests operate on large things, which typically do increase usage, however we noticed that for one reason or another, the test that adds an *uninitialized* ArrayBuffer starts failing on Windows if durability is set to relaxed. There are other ways to make the test fail as well: using a shorter name for the database, or putting small values, does not reliably increase the reported usage. This is all fine in the sense that it isn't defined behavior, but it does suggest that working in this area or on tests of this ilk is a bit of a minefield. These tests probably should not exist as WPT, at least not until quota behavior is specced (see whatwg/storage#110). But it would also be sort of a shame to delete WPT that are passing, so I've left them in place for now. Bug: 1489517 Change-Id: I6619f504ce92e428054691ac6bf54a0e14e3ce5f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4968659 Commit-Queue: Evan Stade <estadechromium.org> Reviewed-by: Ayu Ishii <ayuichromium.org> Cr-Commit-Position: refs/heads/main{#1214324} -- wpt-commits: 446b9bce1ca9a174c11c64f4faa077a9e9d22e72 wpt-pr: 42700 UltraBlame original commit: fe8c71b661e3cce79f0dabbf89fbe7982d82ee99
Automatic update from web-platform-tests Deduplicate some WPT. storagemanager-estimate and estimate-indexeddb are more or less the same tests, the latter having been ported from the former to use `async`/`await`. The former probably should have been deleted when the latter was introduced. Since some of the tests are related to IndexedDB and some are not, this change keeps the IndexedDB tests in the file called `estimate-indexeddb` and keeps the basic tests in `storagemanager-estimate` (with minor updates). One wrinkle from the Chromium side is that the behavior of `storageManager.estimate()` is not actually specced, and as the Chromium implementation uses LevelDB, which behaves in mysterious ways, adding things to the database does NOT always increase the reported usage size. Both of these tests operate on large things, which typically do increase usage, however we noticed that for one reason or another, the test that adds an *uninitialized* ArrayBuffer starts failing on Windows if durability is set to relaxed. There are other ways to make the test fail as well: using a shorter name for the database, or putting small values, does not reliably increase the reported usage. This is all fine in the sense that it isn't defined behavior, but it does suggest that working in this area or on tests of this ilk is a bit of a minefield. These tests probably should not exist as WPT, at least not until quota behavior is specced (see whatwg/storage#110). But it would also be sort of a shame to delete WPT that are passing, so I've left them in place for now. Bug: 1489517 Change-Id: I6619f504ce92e428054691ac6bf54a0e14e3ce5f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4968659 Commit-Queue: Evan Stade <estadechromium.org> Reviewed-by: Ayu Ishii <ayuichromium.org> Cr-Commit-Position: refs/heads/main{#1214324} -- wpt-commits: 446b9bce1ca9a174c11c64f4faa077a9e9d22e72 wpt-pr: 42700 UltraBlame original commit: fe8c71b661e3cce79f0dabbf89fbe7982d82ee99
Automatic update from web-platform-tests Deduplicate some WPT. storagemanager-estimate and estimate-indexeddb are more or less the same tests, the latter having been ported from the former to use `async`/`await`. The former probably should have been deleted when the latter was introduced. Since some of the tests are related to IndexedDB and some are not, this change keeps the IndexedDB tests in the file called `estimate-indexeddb` and keeps the basic tests in `storagemanager-estimate` (with minor updates). One wrinkle from the Chromium side is that the behavior of `storageManager.estimate()` is not actually specced, and as the Chromium implementation uses LevelDB, which behaves in mysterious ways, adding things to the database does NOT always increase the reported usage size. Both of these tests operate on large things, which typically do increase usage, however we noticed that for one reason or another, the test that adds an *uninitialized* ArrayBuffer starts failing on Windows if durability is set to relaxed. There are other ways to make the test fail as well: using a shorter name for the database, or putting small values, does not reliably increase the reported usage. This is all fine in the sense that it isn't defined behavior, but it does suggest that working in this area or on tests of this ilk is a bit of a minefield. These tests probably should not exist as WPT, at least not until quota behavior is specced (see whatwg/storage#110). But it would also be sort of a shame to delete WPT that are passing, so I've left them in place for now. Bug: 1489517 Change-Id: I6619f504ce92e428054691ac6bf54a0e14e3ce5f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4968659 Commit-Queue: Evan Stade <estadechromium.org> Reviewed-by: Ayu Ishii <ayuichromium.org> Cr-Commit-Position: refs/heads/main{#1214324} -- wpt-commits: 446b9bce1ca9a174c11c64f4faa077a9e9d22e72 wpt-pr: 42700 UltraBlame original commit: fe8c71b661e3cce79f0dabbf89fbe7982d82ee99
In order to give developers a more consistent experience across browsers, while allowing browsers to compress, deduplicate, and otherwise optimize the stored data, we should standardize the upper bound for each storage action and have all browsers enforce that.
E.g., the size of
localStorage[key] = value
could be (key's code unit length + value's code unit length) × 2 + 16 bytes of safety padding or some such. (I did not put a lot of thought into this. If we go down this path we'd need to do that.)(See 6 in #95 (comment) and reply for context.)
The text was updated successfully, but these errors were encountered: