Closed
Bug 1385389
Opened 7 years ago
Closed 7 years ago
Consider not deleting the common ancestor hashtable in nsRange::UnregisterCommonAncestor()
Categories
(Core :: DOM: Core & HTML, enhancement)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla57
Tracking | Status | |
---|---|---|
firefox57 | --- | fixed |
People
(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 2 obsolete files)
Deleting this hashtable and recreating it shows up in profiles of bug 1346723.
Perhaps we should consider not doing this extra work given how quickly selections can be changed by the user and script. This can cause us to use a bit more memory but this hashtable should be very small in most cases. The patch is simple, please feel free to r- if you disagree with the change.
Assignee | ||
Comment 1•7 years ago
|
||
Attachment #8891458 -
Flags: review?(bugs)
Assignee | ||
Comment 2•7 years ago
|
||
Comment on attachment 8891458 [details] [diff] [review]
Do not delete the common ancestor ranges hashtable in nsRange::UnregisterCommonAncestor() because chances are we need to recreate it shortly after
This obviously wouldn't work, we need to remove the entry as well.
Attachment #8891458 -
Attachment is obsolete: true
Attachment #8891458 -
Flags: review?(bugs)
Assignee | ||
Comment 3•7 years ago
|
||
Attachment #8891598 -
Flags: review?(bugs)
Comment 4•7 years ago
|
||
Comment on attachment 8891598 [details] [diff] [review]
Do not delete the common ancestor ranges hashtable in nsRange::UnregisterCommonAncestor() because chances are we need to recreate it shortly after
I guess we can try this, but I wonder about the memory use.
I think I'd prefer to limit this to native anonymous content, for now.
Attachment #8891598 -
Flags: review?(bugs)
Updated•7 years ago
|
Assignee: nobody → ehsan
Assignee | ||
Comment 5•7 years ago
|
||
Attachment #8896796 -
Flags: review?(bugs)
Assignee | ||
Updated•7 years ago
|
Attachment #8891598 -
Attachment is obsolete: true
Updated•7 years ago
|
Attachment #8896796 -
Flags: review?(bugs) → review+
Pushed by eakhgari@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/ddc59dc7b92d
Do not delete the common ancestor ranges hashtable in nsRange::UnregisterCommonAncestor() because chances are we need to recreate it shortly after; r=smaug
Comment 7•7 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox57:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Comment 8•7 years ago
|
||
Comment on attachment 8896796 [details] [diff] [review]
Do not delete the common ancestor ranges hashtable in nsRange::UnregisterCommonAncestor() because chances are we need to recreate it shortly after
>+ bool isNativeAnon = aNode->IsInNativeAnonymousSubtree();
>+ bool removed = false;
>+
> if (ranges->Count() == 1) {
> aNode->ClearCommonAncestorForRangeInSelection();
>- aNode->GetCommonAncestorRangesPtr().reset();
>+ if (!isNativeAnon) {
>+ // For nodes which are in native anonymous subtrees, we optimize away the
>+ // cost of deallocating the hashtable here because we may need to create
>+ // it again shortly afterward. We don't do this for all nodes in order
>+ // to avoid the additional memory usage unconditionally.
>+ aNode->GetCommonAncestorRangesPtr().reset();
I'm confused at here. The comment says, "For nodes which are *in* native anonymous subtrees", but the block is used when IsInNativeAnonymousSubtree() returns *false*. Do I misunderstand something??
Flags: needinfo?(ehsan)
Assignee | ||
Comment 9•7 years ago
|
||
(In reply to Masayuki Nakano [:masayuki] (JST, +0900) from comment #8)
> Comment on attachment 8896796 [details] [diff] [review]
> Do not delete the common ancestor ranges hashtable in
> nsRange::UnregisterCommonAncestor() because chances are we need to recreate
> it shortly after
>
> >+ bool isNativeAnon = aNode->IsInNativeAnonymousSubtree();
> >+ bool removed = false;
> >+
> > if (ranges->Count() == 1) {
> > aNode->ClearCommonAncestorForRangeInSelection();
> >- aNode->GetCommonAncestorRangesPtr().reset();
> >+ if (!isNativeAnon) {
> >+ // For nodes which are in native anonymous subtrees, we optimize away the
> >+ // cost of deallocating the hashtable here because we may need to create
> >+ // it again shortly afterward. We don't do this for all nodes in order
> >+ // to avoid the additional memory usage unconditionally.
> >+ aNode->GetCommonAncestorRangesPtr().reset();
>
> I'm confused at here. The comment says, "For nodes which are *in* native
> anonymous subtrees", but the block is used when IsInNativeAnonymousSubtree()
> returns *false*. Do I misunderstand something??
This is a double negative. If the node is not in a native anonymous subtree, we delete the hashtable, otherwise (that is, if the node is inside a native anonymous subtree) we leave the hashtable alone in the hope that it will be reused later.
Flags: needinfo?(ehsan)
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•