Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make querySelectorAll execution parallelized #3039

Open
tetsuharuohzeki opened this issue Aug 6, 2014 · 2 comments
Open

Make querySelectorAll execution parallelized #3039

tetsuharuohzeki opened this issue Aug 6, 2014 · 2 comments

Comments

@tetsuharuohzeki
Copy link
Member

@tetsuharuohzeki tetsuharuohzeki commented Aug 6, 2014

The current our implementation works selector matching parallely in layout code.

However, in script task, we don't make it. Thus ParentNode.querySelectorAll() works sequentially as oldie. This is not good taste.

Parallelized ParentNode.querySelectorAll() will achieve good performance.

@tetsuharuohzeki
Copy link
Member Author

@tetsuharuohzeki tetsuharuohzeki commented Aug 9, 2014

I thought of the implementation design.

Abstract

If we implement this parallelism, we need to know a tree order of matched elements to return an ordered list. Therefore:

  • We would need to add an ordered id (will be uint64) to every elements in Document/DocumentFragment.
  • But if we add an id to every elements on every times which we modify node (document) tree, it will be very high cost.
  • I think that it might be efficient that we add an ordered id to every elements when we traverse an all of nodes in it at the first time after we finished to modify the document.
    • At the first traversing time, we would traverse a tree as sequentially.
    • However, after we added an ordered ids, we would be able to do parallelized selector matching.

This approach will be good if ParentNode.querySelectorAll() is called:

  • at the same point (e.g. document) between the first time and later.
  • at document -> any of elements in the document.
    • We would have added ordered ids to every elements.

But this approach will fail if ParentNode.querySelectorAll() is called:

  • at any of elements in the document -> at the document.
    • We wouldn’t able to add ordered id to every elements, because we need not traverse all elements in the document. If we do so, it would get needless cost :(

In coclusion, this approach will achieve in some speciefed case. But it might be very limited case…

Questions

  • Does this approach have a benefit enough to implement this specified parallel optimization?
    _ Do we have any other good ideas to implement paralleled ParentNode.querySelectorAll()?
@frewsxcv
Copy link
Member

@frewsxcv frewsxcv commented Mar 26, 2016

Potential idea here: Use https://github.com/nikomatsakis/rayon to iterate through the child nodes. Specifically, use the 'parallel iterators' strategy, having one iterator start from firstChild and have one iterator start from lastChild and halting iteration when they reach each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.