Skip to content
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

Consider durability: relaxed for indexeddb writes #2854

Closed
tony-scio opened this issue May 28, 2021 · 1 comment · Fixed by #2934
Closed

Consider durability: relaxed for indexeddb writes #2854

tony-scio opened this issue May 28, 2021 · 1 comment · Fixed by #2934

Comments

@tony-scio
Copy link

Library Affected:
workbox-expiration

Browser & Platform:
Chrome

Issue or Feature Request Description:
Hi, I'm a former chrome engineer working on a web app now. We've studied some chrome traces of our app where the expiration cache timestamps writes get backed up and cause significant contention. This bottleneck can be alleviated by setting durability: relaxed on any readwrite indexeddb transactions. This prevents blocking on disk flushes. It's the default behavior in Firefox and probably will (or should) be the default in Chrome at some point. That's because it's actually a very significant perf gain for a very minor durability sacrifice -- catastrophic events like power failure, OS crash, disk full may cause data loss, but things like browser crash or tab close do not.

There's more detail in the chrome status:
https://www.chromestatus.com/feature/5730701489995776

If this behavior makes sense, the fix would entail changing puts and similar here:

await db.put(CACHE_OBJECT_STORE, entry);

Slow (current):

await db.put(CACHE_OBJECT_STORE, entry);

Fast (untested in this context):

const tx = db.transaction(CACHE_OBJECT_STORE, 'readwrite', { durability: 'relaxed' });
await tx.store.put(CACHE_OBJECT_STORE, entry);
await tx.done;
@jeffposnick
Copy link
Contributor

Thanks for bringing this up—@tropicadri is now our resident IndexedDB expert, and I'll let her weigh in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants