Bug 97738 - IndexedDB: Run multiple tasks per transaction tick
Summary: IndexedDB: Run multiple tasks per transaction tick
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Joshua Bell
URL:
Keywords:
Depends on: 97933
Blocks:
  Show dependency treegraph
 
Reported: 2012-09-26 16:19 PDT by Joshua Bell
Modified: 2012-11-16 12:05 PST (History)
6 users (show)

See Also:


Attachments
Patch (4.12 KB, patch)
2012-09-26 16:21 PDT, Joshua Bell
no flags Details | Formatted Diff | Diff
Patch (2.96 KB, patch)
2012-09-27 09:13 PDT, Joshua Bell
no flags Details | Formatted Diff | Diff
Patch for landing (3.13 KB, patch)
2012-09-27 16:47 PDT, Joshua Bell
no flags Details | Formatted Diff | Diff
Patch for landing (3.06 KB, patch)
2012-09-28 09:17 PDT, Joshua Bell
no flags Details | Formatted Diff | Diff
Patch for landing (3.12 KB, patch)
2012-11-13 15:50 PST, 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-09-26 16:19:02 PDT
IndexedDB: Pair of performance fixes
Comment 1 Joshua Bell 2012-09-26 16:21:02 PDT
Created attachment 165893 [details]
Patch
Comment 2 Joshua Bell 2012-09-26 16:21:31 PDT
alecflett@, dgrogan@ - can you take a look?
Comment 3 David Grogan 2012-09-26 16:47:13 PDT
Comment on attachment 165893 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=165893&action=review

> Source/WebCore/ChangeLog:9
> +        via profiling in string encoding (pro-tip: if it's already UChar, just memcpy);

The old way doesn't provide robustness in the face of different endianness?  Sorry if that's a stupid question.

> Source/WebCore/Modules/indexeddb/IDBLevelDBCoding.cpp:293
> +    size_t len = s.length() * sizeof(UChar);

Is there any advantage to passing len to the Vector constructor like line 292-old does?

> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:258
> +    TaskQueue* taskQueue = m_pendingPreemptiveEvents ? &m_preemptiveTaskQueue : &m_taskQueue;

This seems like the type of innocuous-looking change that causes some other non-robust portion of our code to start behaving non-deterministically, but I don't really know what's going on. I'll let Alec comment.
Comment 4 Joshua Bell 2012-09-26 16:57:21 PDT
(In reply to comment #3)
> (From update of attachment 165893 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=165893&action=review
> 
> > Source/WebCore/ChangeLog:9
> > +        via profiling in string encoding (pro-tip: if it's already UChar, just memcpy);
> 
> The old way doesn't provide robustness in the face of different endianness?  Sorry if that's a stupid question.

It's a great question, actually.

The old method actually defends against different endianness by always reading/writing as big endian... which would be a breaking format change since most architectures are little endian. Derp.

(I was under the impression that leveldb stores weren't portable across different-endian architectures which is why I blithely made the change.)

I'll split this patch up and maybe turf this one.

> > Source/WebCore/Modules/indexeddb/IDBLevelDBCoding.cpp:293
> > +    size_t len = s.length() * sizeof(UChar);
> 
> Is there any advantage to passing len to the Vector constructor like line 292-old does?

Hrm, there probably is, since IIRC Vector has a default size.
 
> > Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:258
> > +    TaskQueue* taskQueue = m_pendingPreemptiveEvents ? &m_preemptiveTaskQueue : &m_taskQueue;
> 
> This seems like the type of innocuous-looking change that causes some other non-robust portion of our code to start behaving non-deterministically, but I don't really know what's going on. I'll let Alec comment.
Comment 5 WebKit Review Bot 2012-09-26 17:11:19 PDT
Comment on attachment 165893 [details]
Patch

Attachment 165893 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14018723

New failing tests:
IDBLevelDBCodingTest.CompareEncodedStringsWithLength
storage/indexeddb/cursor-key-order.html
IDBLevelDBCodingTest.DecodeString
IDBLevelDBCodingTest.DecodeIDBKeyPath
Comment 6 Joshua Bell 2012-09-27 08:59:12 PDT
(In reply to comment #5)
> (From update of attachment 165893 [details])
> Attachment 165893 [details] did not pass chromium-ews (chromium-xvfb):
> Output: http://queues.webkit.org/results/14018723
> 
> New failing tests:
> IDBLevelDBCodingTest.CompareEncodedStringsWithLength
> storage/indexeddb/cursor-key-order.html
> IDBLevelDBCodingTest.DecodeString
> IDBLevelDBCodingTest.DecodeIDBKeyPath

Awesome - we do have endianness tests, which saved the day.

I'll split this up and add a string endianness switch as a future perf item.
Comment 7 Joshua Bell 2012-09-27 09:13:11 PDT
Created attachment 166013 [details]
Patch
Comment 8 Alec Flett 2012-09-27 11:12:18 PDT
Comment on attachment 166013 [details]
Patch

LGTM
Comment 9 Joshua Bell 2012-09-27 12:57:22 PDT
tony@ - r?
Comment 10 Tony Chang 2012-09-27 14:15:32 PDT
Comment on attachment 166013 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=166013&action=review

> Source/WebCore/ChangeLog:9
> +        Process multiple tasks from the pending queue(s) when the timer fires. The
> +        task may initiate new tasks that change which queue is active (e.g. indexing

Per times (like the time to run all the LayoutTests before/after this change) would be nice.
Comment 11 Joshua Bell 2012-09-27 16:47:44 PDT
Created attachment 166093 [details]
Patch for landing
Comment 12 WebKit Review Bot 2012-09-27 17:11:07 PDT
Comment on attachment 166093 [details]
Patch for landing

Rejecting attachment 166093 [details] from commit-queue.

Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2

Last 500 characters of output:

Failed to run "['Tools/Scripts/update-webkit', '--chromium', '--force-update']" exit_code: 9
Updating OpenSource
From http://git.chromium.org/external/Webkit
   82bc0a1..e7aca46  master     -> origin/master
Partial-rebuilding .git/svn/refs/remotes/origin/master/.rev_map.268f45cc-cd09-0410-ab3c-d52691b4dbfc ...
Currently at 129817 = c176af8a903a16f338b44f42a58940a7dedc9084
last_rev is higher!: 129817 >= 129802 at /usr/lib/git-core/git-svn line 1523

Died at Tools/Scripts/update-webkit line 164.

Full output: http://queues.webkit.org/results/14034982
Comment 13 Joshua Bell 2012-09-28 09:17:16 PDT
Created attachment 166265 [details]
Patch for landing
Comment 14 WebKit Review Bot 2012-09-28 09:38:41 PDT
Comment on attachment 166265 [details]
Patch for landing

Clearing flags on attachment: 166265

Committed r129911: <http://trac.webkit.org/changeset/129911>
Comment 15 WebKit Review Bot 2012-09-28 09:38:45 PDT
All reviewed patches have been landed.  Closing bug.
Comment 16 WebKit Review Bot 2012-09-28 13:21:40 PDT
Re-opened since this is blocked by bug 97933
Comment 17 Joshua Bell 2012-09-28 13:45:12 PDT
(In reply to comment #16)
> Re-opened since this is blocked by bug 97933

Two theories so far, with no evidence:

* This change means that tasks may execute even before the previous task calls didCompleteTaskEvents if there's async operation in between (e.g. firing onSuccess across an IPC boundary). Possibly something is sensitive to that, as the InspectorIndexedDBAgent does explicitly call didCompleteTaskEvents().

* m_taskEventTimer.startOneShot(0) may be called repeatedly now without waiting for the previous call to fire. Perhaps there's something on Windows that's sensitive to this?
Comment 19 Joshua Bell 2012-11-13 15:50:32 PST
Created attachment 174015 [details]
Patch for landing
Comment 20 Joshua Bell 2012-11-13 15:53:57 PST
Trying this again. I was never able to repro the inspector crash (locally or with the try bots). 

The IndexedDB inspector code has since been completely re-written; it used to use  back-end APIs, and needed to explicitly poke a "private" API (didCompleteTaskEvents) to signal that tasks were complete, and some re-entrancy problem induced by this platform-specific timer behavior was my suspicion for the cause of the crash. The way the inspector talks to IDB has completely changed to only use front-end APIs, so I believe that this should be safe now.

...

Gardeners - if tests start crashing after this lands, please roll it out.
Comment 21 WebKit Review Bot 2012-11-13 20:34:11 PST
Comment on attachment 174015 [details]
Patch for landing

Clearing flags on attachment: 174015

Committed r134529: <http://trac.webkit.org/changeset/134529>
Comment 22 WebKit Review Bot 2012-11-13 20:34:16 PST
All reviewed patches have been landed.  Closing bug.