Bug 102717 - Use traverseNextNode in gcTree
Summary: Use traverseNextNode in gcTree
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Elliott Sprehn
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-19 14:45 PST by Elliott Sprehn
Modified: 2012-11-19 16:50 PST (History)
4 users (show)

See Also:


Attachments
Patch (3.27 KB, patch)
2012-11-19 14:48 PST, Elliott Sprehn
no flags Details | Formatted Diff | Diff
Patch (3.26 KB, patch)
2012-11-19 15:06 PST, Elliott Sprehn
haraken: review+
haraken: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Elliott Sprehn 2012-11-19 14:45:10 PST
Use traverseNextNode in gcTree
Comment 1 Elliott Sprehn 2012-11-19 14:48:14 PST
Created attachment 175045 [details]
Patch
Comment 2 Elliott Sprehn 2012-11-19 14:52:13 PST
In Bug 98725 haraken said that this traversal was different than traverseNextNode but near as I can tell it's identical to what traverseNextNode(stayWithin) does and that method is inline so it doesn't make any sense that it would be faster to manually inline it instead of letting the compiler do it.
Comment 3 Adam Barth 2012-11-19 14:56:25 PST
This looks like a patch for haraken to review.
Comment 4 Elliott Sprehn 2012-11-19 15:06:00 PST
Created attachment 175050 [details]
Patch
Comment 5 Kentaro Hara 2012-11-19 16:33:34 PST
Comment on attachment 175050 [details]
Patch

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

> Source/WebCore/bindings/v8/V8GCController.cpp:227
> +    for (Node* node = startNode; node; node->traverseNextNode(startNode)) {

traverseNextNode() returns 0 when it reaches a root node, doesn't it? Here we need to do the DOM traversal until the traversal gets back to startNode.

Adding a couple of branches will solve the problem. That being said, the number of if instructions will be fewer in the current code than the code that uses traverseNextNode() + some additional branches. (I don't know whether it is really important for performance though.)
Comment 6 Elliott Sprehn 2012-11-19 16:36:32 PST
(In reply to comment #5)
> (From update of attachment 175050 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=175050&action=review
> 
> > Source/WebCore/bindings/v8/V8GCController.cpp:227
> > +    for (Node* node = startNode; node; node->traverseNextNode(startNode)) {
> 
> traverseNextNode() returns 0 when it reaches a root node, doesn't it? Here we need to do the DOM traversal until the traversal gets back to startNode.
> 
> Adding a couple of branches will solve the problem. That being said, the number of if instructions will be fewer in the current code than the code that uses traverseNextNode() + some additional branches. (I don't know whether it is really important for performance though.)

What do you mean by reaches a root note? traverseNextNode(stayWithin) does exactly what your code does, it traverses down and back up until it reaches the node you pass into it (startNode).

I also don't understand why this would be more instructions, it's an inline method call. It would produce essentially identical code.
Comment 7 Elliott Sprehn 2012-11-19 16:39:38 PST
(In reply to comment #6)
> ...
> 
> I also don't understand why this would be more instructions, it's an inline method call. It would produce essentially identical code.

Actually I see that Node::traverseNextAncestorSibling is not inline, still this feels like premature optimization.
Comment 8 Kentaro Hara 2012-11-19 16:47:19 PST
Comment on attachment 175050 [details]
Patch

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

>>> Source/WebCore/bindings/v8/V8GCController.cpp:227
>>> +    for (Node* node = startNode; node; node->traverseNextNode(startNode)) {
>> 
>> traverseNextNode() returns 0 when it reaches a root node, doesn't it? Here we need to do the DOM traversal until the traversal gets back to startNode.
>> 
>> Adding a couple of branches will solve the problem. That being said, the number of if instructions will be fewer in the current code than the code that uses traverseNextNode() + some additional branches. (I don't know whether it is really important for performance though.)
> 
> What do you mean by reaches a root note? traverseNextNode(stayWithin) does exactly what your code does, it traverses down and back up until it reaches the node you pass into it (startNode).
> 
> I also don't understand why this would be more instructions, it's an inline method call. It would produce essentially identical code.

Ah, got it. I was misunderstanding traverseNextNode(stayWithin) and traverseNextNode(). Your patch looks correct.

As for performance, the current code will be a win, though I don't know it's a meaningful win. Would you confirm that it won't regress performance before landing? You can use this benchmark: https://bugs.webkit.org/attachment.cgi?id=169542 and observe minor GC cycle times by ./out/Release/chrome --js-flags="--trace-gc".
Comment 9 Elliott Sprehn 2012-11-19 16:50:34 PST
(In reply to comment #8)
> ..
> 
> As for performance, the current code will be a win, though I don't know it's a meaningful win. Would you confirm that it won't regress performance before landing? You can use this benchmark: https://bugs.webkit.org/attachment.cgi?id=169542 and observe minor GC cycle times by ./out/Release/chrome --js-flags="--trace-gc".

Sure.