GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Define flush-to-disk guarantees and control · Issue #50 · w3c/IndexedDB

Define flush-to-disk guarantees and control #50

New issue
Copy link
New issue
Copy link
Closed
#301
Closed
Define flush-to-disk guarantees and control#50
#301
Copy link
Labels
TPAC 2019Discuss at FukuokaDiscuss at Fukuokablink +1feature requestfeedback wantedgecko +1has-prhas-testsperformance
Milestone
V3

Description

@inexorabletash
inexorabletash
opened on Oct 7, 2015
Issue body actions

Define flushing guarantees and expose control
e.g. make transactions not flush-to-disk by default, but introduce a "readwriteflush" mode or {flush: true} option

Currently, FF does not flush (but wants an option), Chrome always flushes.

Activity

  1. inexorabletash
    added
    feature request
    feedback wanted
    performance
    gecko +1
    on Oct 7, 2015
  2. sicking commented on Oct 7, 2015

    @sicking
    sicking
    on Oct 7, 2015
    Contributor
    More actions

    Yeah. We found this to be a big performance issue. So we'd definitely like to have this. Most likely the right default would be to not flush since many times developers use IndexedDB as an async version of localStorage.

  3. inexorabletash
    added
    blink +1
    on Oct 8, 2015
  4. inexorabletash commented on Oct 8, 2015

    @inexorabletash
    inexorabletash
    on Oct 8, 2015
    MemberAuthor
    More actions

    I think we're in favor of this too, just a matter of ensuring out backing store is up for this.

  5. beidson commented on May 12, 2016

    @beidson
    beidson
    on May 12, 2016
    More actions

    The spec has long explicitly required both the A and D of ACID, and probably implicitly requires the C and I. The spec should not get into requiring specific implementation details of that ACIDity.

    If an implementation can be ACID without flushing, good for them.

    If an implementation see's a noticeable performance hit while flushing, they should work on that.

    I think this would be complexity inappropriate for a web-facing API, and we will be against making it a requirement.

    Reacted by Linz
  6. inexorabletash
    added
    TPAC 2019Discuss at FukuokaDiscuss at Fukuoka
    on Jun 14, 2019
  7. inexorabletash commented on Jun 14, 2019

    @inexorabletash
    inexorabletash
    on Jun 14, 2019
    MemberAuthor
    More actions

    For performance reasons, we (Chrome) are considering making the flush optional. Example:

    db.transaction(scope, "readwrite", {preventFlush: true});
  8. pwnall commented on Jun 18, 2019

    @pwnall
    pwnall
    on Jun 18, 2019
    More actions

    I like relaxedDurability: true a bit more, because it doesn't make any implementation promises. Also, I think the word flush was poisoned, because POSIX has fflush (write to OS buffer cache) / fsync (write to storage medium) while Windows has FlushFileBuffers that writes to the storage medium.

    To be clear, we (Chrome) would like to provide a mode that skips writing to the storage medium (fsync). We're not currently interested in skipping the fflush, because the cost of writing to the OS is small compared to typical IPC overhead.

    Also, I wouldn't be against Firefox's approach of disabling fsync by default and requiring applications to opt in. Handling power failures is very subtle, and I don't think it's too bad to assume that no apps do it correctly today, so I think it'd make sense to ask developers to explicitly opt into stronger durability guarantees.

  9. asutherland commented on Aug 27, 2019

    @asutherland
    asutherland
    on Aug 27, 2019
    Collaborator
    More actions

    Aside

    To clarify, Firefox's IndexedDB is built on top on SQLite and since 2015 has used its Write-Ahead-Log in PRAGMA synchronous=NORMAL mode (SQLite docs). This is supposed to provide durability in the face of browser crashes but may rollback on device crashes.

    On the issue

    I'd like to instead propose that we address this via storage buckets. When creating a bucket, the site would specify what level of durability it wants the bucket to have (among other things). This provides a ton of implementer latitude just beyond "do we do an fsync at the end", as well as providing a gateway to improved storage eviction and improved user control on what's being stored on their device.

    Also, in the event corruption of a database happens (which realistically is a thing that can happen, although thankfully we're past some of the darkest days of this), it makes it easier to limit the spillover damage. I think in theory, per spec, browsers would wipe the entire origin if any database in the origin became corrupt, but in practice I suspect they all just throw errors on the database until you delete it. Buckets would help with this too.

  10. inexorabletash commented on Sep 19, 2019

    @inexorabletash
    inexorabletash
    on Sep 19, 2019
    MemberAuthor
    More actions

    TPAC 2019 Web Apps breakout: #CaliforniaRelaxed

    • Attendees agreed with durability control on storage buckets as useful
    • Attendees agreed that allowing durability control on transactions was also fine, as long as these are not in conflict
    • Proposed switching proposal from a boolean to an enum allows for this: "strict", "relaxed", "default" - the latter would inherit from the bucket's default.

    IDL sketch:

    enum IDBTransactionDurability { "default", "strict", "relaxed" };
    
    dictionary IDBTransactionOptions {
        IDBTransactionDurability durability = "default";
    };
    
    // in IDBDatabase:
      ...
      [NewObject] IDBTransaction transaction(
           (DOMString or sequence<DOMString>) storeNames,
           optional IDBTransactionMode mode = "readonly",
           optional IDBTransactionOptions options = {});
      ...

    @asutherland - how does that look? Happy to bikeshed the naming.

    Also: Should we add a readonly durability property on IDBTransaction to allow introspection? Since this property is a hint to the UA it's not as critical as in other cases.

  11. inexorabletash
    added this to the V3 milestone on Sep 20, 2019
  12. asutherland commented on Sep 20, 2019

    @asutherland
    asutherland
    on Sep 20, 2019
    Collaborator
    More actions

    Looks good. We already have consensus on this, but we want to make sure the spec definition of durability should come from the buckets spec once that exists. (Not just inheriting of the behavior.)

    At triage just now, we've also agreed that exposing the durability property makes sense.

  13. inexorabletash commented on Sep 24, 2019

    @inexorabletash
    inexorabletash
    on Sep 24, 2019
    MemberAuthor
    More actions

    Awesome. Any volunteers to write a spec PR here?

    (IMHO we can start sketching out a definition of durability here and then migrate it to Storage when Buckets land.)

  14. inexorabletash
    added a commit that references this issue on Sep 26, 2019

    Sketch out spec text for durability. Fixes #50

    This issue will close once commit 1f8b9a4 is merged into the 'main' branch.
    1f8b9a4
  15. inexorabletash
    added
    has-pr
    has-tests
    on Sep 26, 2019
  16. inexorabletash
    added a commit that references this issue on Sep 30, 2019

    Sketch out spec text for durability. Fixes #50

    This issue will close once commit b4422ef is merged into the 'main' branch.
    b4422ef
  17. inexorabletash
    added a commit that references this issue on Oct 18, 2019

    Sketch out spec text for durability. Fixes #50

    This issue will close once commit 82ee311 is merged into the 'main' branch.
    82ee311
  18. inexorabletash
    added 2 commits that reference this issue on Nov 26, 2019

    Sketch out spec text for durability. Fixes #50

    This issue will close once commit 4d4ae3b is merged into the 'main' branch.
    4d4ae3b

    Sketch out spec text for durability. Fixes #50

    This issue will close once commit 27681a2 is merged into the 'main' branch.
    27681a2
  19. inexorabletash
    closed this as completedin #301on Jan 22, 2020
  20. inexorabletash
    added a commit that references this issue on Jan 22, 2020

    Add transaction durability option

    This issue will close once commit 1a519e7 is merged into the 'main' branch.
    1a519e7
  21. inexorabletash
    added a commit that references this issue on Feb 1, 2021

    Add transaction durability option

    This issue will close once commit 1c6a04b is merged into the 'main' branch.
    1c6a04b
  22. nolanlawson commented on Apr 9, 2021

    @nolanlawson
    nolanlawson
    on Apr 9, 2021
    Member
    More actions

    I see that relaxed durability has landed in Chrome 83: https://www.chromestatus.com/feature/5730701489995776

    Is there a benchmark that demonstrates the performance difference between relaxed and strict durability? Looking at the Chromium commit, it references a benchmark in a Chromium bug that appears to be Google-internal.

    I tried it myself, and so far I am not able to see a performance difference, but I'm not sure exactly what kind of workload would suss out the difference. However anecdotally, I do see the same kind of performance differences between Chromium and other engines described in this post.

  23. pwnall commented on Jun 30, 2021

    @pwnall
    pwnall
    on Jun 30, 2021
    More actions

    @nolanlawson Sorry, I just noticed your comment here. I opened up the bug referenced by the commit. I opened up the bug mentioned above. The benchmark in this comment may also help.

    Reacted by Nolan Lawson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    TPAC 2019Discuss at FukuokaDiscuss at Fukuokablink +1feature requestfeedback wantedgecko +1has-prhas-testsperformance

    Type

    No type

    Projects

    No projects

      Milestone

      • V3

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.