Bug 99884 - [V8] Vastly simplify V8GCController's NodeVisitor
Summary: [V8] Vastly simplify V8GCController's NodeVisitor
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: Adam Barth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-19 16:20 PDT by Adam Barth
Modified: 2012-10-22 11:50 PDT (History)
6 users (show)

See Also:


Attachments
Patch (9.73 KB, patch)
2012-10-19 16:22 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
Updated patch with new PerformanceTests (12.25 KB, patch)
2012-10-20 18:08 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
perf test results (first five are with patch; last five are without) (44.79 KB, text/html)
2012-10-20 18:09 PDT, Adam Barth
no flags Details
Updated patch with new PerformanceTests (12.91 KB, patch)
2012-10-20 18:17 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
gc-mini-tree (first three are with patch; last three are without) (27.91 KB, text/html)
2012-10-20 18:18 PDT, Adam Barth
no flags Details
Patch (11.09 KB, patch)
2012-10-20 18:29 PDT, Adam Barth
abarth: review-
Details | Formatted Diff | Diff
Patch (10.88 KB, patch)
2012-10-20 23:05 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
Patch for landing (12.69 KB, patch)
2012-10-22 11:19 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
Patch for landing (12.73 KB, patch)
2012-10-22 11:21 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
Perf test results (first five are without patch; second five are with patch) (56.86 KB, text/html)
2012-10-22 11:24 PDT, Adam Barth
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2012-10-19 16:20:14 PDT
[V8] Vastly simplify V8GCController's NodeVisitor
Comment 1 Adam Barth 2012-10-19 16:22:09 PDT
Created attachment 169718 [details]
Patch
Comment 2 Adam Barth 2012-10-19 16:35:49 PDT
I didn't mention this in the ChangeLog, but I also got rid of an entire memcpy.
Comment 3 Eric Seidel (no email) 2012-10-19 19:31:39 PDT
Comment on attachment 169718 [details]
Patch

On heavy-GC tests, this should show a speed win, no?
Comment 4 Kentaro Hara 2012-10-19 19:38:52 PDT
Comment on attachment 169718 [details]
Patch

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

Looks good at a first glance. Let me take a detailed look later.

> Source/WebCore/bindings/v8/V8GCController.cpp:136
> +    // FIXME: What about <audio>?

Are you caring about that <audio> is an active Node?
Comment 5 Adam Barth 2012-10-19 20:53:54 PDT
(In reply to comment #4)
> (From update of attachment 169718 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=169718&action=review
> 
> Looks good at a first glance. Let me take a detailed look later.
> 
> > Source/WebCore/bindings/v8/V8GCController.cpp:136
> > +    // FIXME: What about <audio>?
> 
> Are you caring about that <audio> is an active Node?

Oh, you're right.  <audio> inherits from HTMLMediaElement.  I'll remove the comment.
Comment 6 Adam Barth 2012-10-19 20:54:25 PDT
> On heavy-GC tests, this should show a speed win, no?

Yes.  We can try it on Kentaro's createElement case if you like.
Comment 7 Eric Seidel (no email) 2012-10-20 15:49:39 PDT
I would like to see the perf results if possible.  On whatever benchmark you like of course.
Comment 8 Adam Barth 2012-10-20 18:08:51 PDT
Created attachment 169779 [details]
Updated patch with new PerformanceTests
Comment 9 Adam Barth 2012-10-20 18:09:41 PDT
Created attachment 169780 [details]
perf test results (first five are with patch; last five are without)
Comment 10 Adam Barth 2012-10-20 18:17:14 PDT
Created attachment 169781 [details]
Updated patch with new PerformanceTests
Comment 11 Adam Barth 2012-10-20 18:18:42 PDT
Created attachment 169782 [details]
gc-mini-tree (first three are with patch; last three are without)

Just for fun, I added a third PerformanceTest with a workload that shows the new algorithm running 20% faster than the old algorithm.
Comment 12 Adam Barth 2012-10-20 18:29:15 PDT
Created attachment 169783 [details]
Patch
Comment 13 Adam Barth 2012-10-20 20:22:05 PDT
Comment on attachment 169783 [details]
Patch

Looks like I broke some tests.  :(
Comment 14 Eric Seidel (no email) 2012-10-20 20:30:43 PDT
Comment on attachment 169783 [details]
Patch

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

> Source/WebCore/bindings/v8/V8GCController.cpp:136
> +    // FIXME: What about <audio>?

What's this about?

> Source/WebCore/bindings/v8/V8GCController.cpp:147
> +    while (Node* parent = node->parentOrHostNode())
> +        node = parent;

Don't we already have a function for this?

> Source/WebCore/bindings/v8/V8GCController.cpp:170
> +bool operator<(const ImplicitReference& lhs, const ImplicitReference& rhs)
> +{
> +    return lhs.root() < rhs.root();

I would have named these "left" and "right"

> Source/WebCore/bindings/v8/V8GCController.cpp:208
> +            currentGroup.shrink(0);

Why?  And if so, why not have the Vector declared in the for loop block?
Comment 15 Adam Barth 2012-10-20 20:41:19 PDT
(In reply to comment #14)
> (From update of attachment 169783 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=169783&action=review
> 
> > Source/WebCore/bindings/v8/V8GCController.cpp:136
> > +    // FIXME: What about <audio>?
> 
> What's this about?

Kentaro pointed out in Comment #4 that <audio> is fine because it's a subclass of HTMLMediaElement, which is an ActiveDOMObject.

> > Source/WebCore/bindings/v8/V8GCController.cpp:147
> > +    while (Node* parent = node->parentOrHostNode())
> > +        node = parent;
> 
> Don't we already have a function for this?

Not that I know of.

> > Source/WebCore/bindings/v8/V8GCController.cpp:170
> > +bool operator<(const ImplicitReference& lhs, const ImplicitReference& rhs)
> > +{
> > +    return lhs.root() < rhs.root();
> 
> I would have named these "left" and "right"
> 
> > Source/WebCore/bindings/v8/V8GCController.cpp:208
> > +            currentGroup.shrink(0);
> 
> Why?  And if so, why not have the Vector declared in the for loop block?

That's the trick that saves 20% on gc-mini-tree.  If we declared the vector in the for loop block, we'd have to malloc it every time.  Using shrink lets us re-use the buffer for each iteration.
Comment 16 Adam Barth 2012-10-20 23:05:18 PDT
Created attachment 169786 [details]
Patch
Comment 17 Adam Barth 2012-10-21 09:59:22 PDT
I should re-run the benchmarks with the updated patch.  I'm sure it's not a regression.  I'm just not sure if mini-tree will show the same improvement.
Comment 18 Kentaro Hara 2012-10-21 23:45:48 PDT
Comment on attachment 169786 [details]
Patch

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

Looks OK. Please just re-run the benchmarks and verify the speed-up.

> PerformanceTests/ChangeLog:12
> +        * Bindings/gc-forest.html: Added.
> +        * Bindings/gc-mini-tree.html: Added.
> +        * Bindings/gc-tree.html: Added.

It looks like you missed adding these tests.
Comment 19 Adam Barth 2012-10-22 11:19:25 PDT
Created attachment 169943 [details]
Patch for landing
Comment 20 Adam Barth 2012-10-22 11:21:33 PDT
Created attachment 169944 [details]
Patch for landing
Comment 21 Adam Barth 2012-10-22 11:24:14 PDT
Created attachment 169945 [details]
Perf test results (first five are without patch; second five are with patch)

Here's a summary of the perf tests results (average of five runs):

gc-forest: 1.14% better
gc-mini-tree: 5.09% better
gc-tree: 4.60% better

The performance improvements are icing on this patch (in my view).  The main thing I wanted to do here is to delete the nutty code.  :)
Comment 22 WebKit Review Bot 2012-10-22 11:50:21 PDT
Comment on attachment 169944 [details]
Patch for landing

Clearing flags on attachment: 169944

Committed r132114: <http://trac.webkit.org/changeset/132114>
Comment 23 WebKit Review Bot 2012-10-22 11:50:26 PDT
All reviewed patches have been landed.  Closing bug.