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

Optimize the named property tracker by not walking the entire tree #1174

Merged
merged 2 commits into from Jul 26, 2015
Merged

Optimize the named property tracker by not walking the entire tree #1174

merged 2 commits into from Jul 26, 2015

Conversation

Joris-van-der-Wel
Copy link
Member

This was one of the thing slowing down #1156 (w3c/respec#453).

The included benchmark has these results:

before: jsdom x 0.19 ops/sec ±68.89% (5 runs sampled)
after: jsdom x 3,054 ops/sec ±7.63% (29 runs sampled)

The named property tracker has been refactored by making the tracking and untracking more explicit. The tracker now keeps a list of potential values for a specific named property. The resolver function that is used for the window no longer walks the entire tree, but receives that list of potential values. It can then filter on that list and sort it in tree order using compareDocumentPosition. This works fast because compareDocumentPosition has been optimized in #1169.

Testing if a named property can be untracked is now many times faster, which means `setAttribute()` and `removeChild()` will not be slowed by it.
Looking up a named property will also be faster for huge documents
@domenic
Copy link
Member

domenic commented Jul 26, 2015

LGTM! No merge commits this time; --ff-only :)

@Joris-van-der-Wel Joris-van-der-Wel merged commit bcf0533 into jsdom:master Jul 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants