Bug 89239 - IndexedDB: Don't do full commit for empty transactions
Summary: IndexedDB: Don't do full commit for empty transactions
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Joshua Bell
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-15 12:12 PDT by Joshua Bell
Modified: 2012-10-03 16:48 PDT (History)
5 users (show)

See Also:


Attachments
Patch (1.52 KB, patch)
2012-07-19 16:14 PDT, Joshua Bell
no flags Details | Formatted Diff | Diff
Patch (1.77 KB, patch)
2012-10-03 15:26 PDT, Joshua Bell
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Bell 2012-06-15 12:12:38 PDT
For read-only IDB transactions we go through the full motions of an backing store commit, including creating/writing a (presumably empty) leveldb writebatch.

This can be short-circuited, which would eliminate unnecessary work and make the read-only transaction resilient to backing store faults (e.g. disk has gone away but data is still in memory)
Comment 1 Joshua Bell 2012-07-19 16:14:24 PDT
Created attachment 153369 [details]
Patch
Comment 2 Joshua Bell 2012-07-19 16:15:47 PDT
I don't know if we actually want this... the only practical upshot is that if leveldb has entered a bad state due to I/O error the read transaction won't trip it if the data is in an in-memory table.
Comment 3 David Grogan 2012-07-20 14:01:04 PDT
Comment on attachment 153369 [details]
Patch

LGTM

Bike-shedding: Agreed that the desirability question doesn't have a clear answer. My vote would be to add this code, only because there's a conceivable scenario where a docs user wants to be able to read their docs offline even if they can't write due to some flaw in either our code or docs'. I suppose the downside is that this could make such errors less discoverable.  No strong opinion.

If you do add this code, could you add a comment indicating how it could matter?
Comment 4 Alec Flett 2012-07-23 16:34:34 PDT
My vote is also to land this - I think this also helps in the case of a database going read-only, filling up, or overrunning quota, right? (Not all of that may kick this in today...) 

Seems like the downside is a tiny amount of code complexity, but it's pretty darn minor. Also agreed on the comment - the "if (m_tree.is_empty())" does not read "if this is a read-only transaction" to me - though maybe the naming of m_tree is the culprit there. not sure.
Comment 5 Joshua Bell 2012-09-18 12:17:36 PDT
Comment on attachment 153369 [details]
Patch

What happens when we iterate a cursor during a read-only transaction - do we clean up stale entries? Should those be committed or should that wait for a follow-up read/write transaction?

If we commit, then this doesn't address the scenario where this is defensive against I/O errors.

If we don't commit, all subsequent transactions pay that penalty.

Also note that the patch as written checks at a lower level - if index cleanup was done, it would still commit, so it's actually moot for this patch. I'm tempted to land it as-is, but perhaps make the bug title less grandiose.
Comment 6 Joshua Bell 2012-10-03 15:11:46 PDT
Changed title to "don't do full commit for empty transactions"

Read-only transactions can still be non-empty if they include index cleanup.
Comment 7 Joshua Bell 2012-10-03 15:26:42 PDT
Created attachment 166971 [details]
Patch
Comment 8 Joshua Bell 2012-10-03 15:28:48 PDT
michaeln@ came up with the same patch when looking into performance for read-only transactions:

https://groups.google.com/a/chromium.org/d/msg/chromium-html5/FRbwyUgspQ0/2xZkWZv1zQAJ
Comment 9 Joshua Bell 2012-10-03 15:29:09 PDT
tony@ - r?
Comment 10 WebKit Review Bot 2012-10-03 16:13:45 PDT
Comment on attachment 166971 [details]
Patch

Clearing flags on attachment: 166971

Committed r130338: <http://trac.webkit.org/changeset/130338>
Comment 11 WebKit Review Bot 2012-10-03 16:13:49 PDT
All reviewed patches have been landed.  Closing bug.
Comment 12 Michael Nordman 2012-10-03 16:48:10 PDT
Woohoo... nice low hanging watermelon sized 10x improvement in small reads :)