Implement discarding Document objects to reclaim space.#14312
Implement discarding Document objects to reclaim space.#14312bors-servo merged 5 commits intoservo:masterfrom
Conversation
|
Maybe the name of that flag needs unsafe in it? It seems a little confusingly worded as is. |
|
☔ The latest upstream changes (presumably #14313) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@metajack: yes, that option name isn't my best-ever writing. |
e398d45 to
376f059
Compare
|
☔ The latest upstream changes (presumably #14211) made this pull request unmergeable. Please resolve the merge conflicts. |
376f059 to
39f3cea
Compare
|
Might be worth disabling this by default, and enabling it with a flag? |
|
@asajeffrey Why disable by default? |
|
@metajack just being conservative. This change makes servo a lot more like FF, in that back/fwd will almost always result in a reload. This is not necessarily bad, but it is different. |
|
Leaving it off by default will make it consume infinite memory, no? I can see a case for some middle ground setting being desireable, but I assume that is much more complex to guarantee since somehow we will have to keep the appropriate pipelines alive artificially. |
|
@metajack yes, there are more space leaks without this PR than with it. It wouldn't be too hard to implement whatever heuristic we want, we just add a message from the constellation to the script thread saying when a pipeline is discardable. I just piggybacked freeze/thaw because it was already there. |
components/script/script_thread.rs
Outdated
| /// The state that a document managed by this script thread could be in. | ||
| #[must_root] | ||
| enum DocumentState { | ||
| Kept(bool, JS<Document>), |
There was a problem hiding this comment.
Could you document what this bool means? I guess it's thawed, but would be ok to have it written here, or alternatively add a binary enum or a Kept { thawed: bool, document: JS<Document> } instead of a plain bool.
components/script/script_thread.rs
Outdated
| fn trace(&self, trc: *mut JSTracer) { | ||
| // Note: we only trace thawed documents. | ||
| if let DocumentState::Kept(true, ref doc) = *self { | ||
| doc.trace(trc); |
There was a problem hiding this comment.
Why is this needed? Just derive the trait on DocumentState.
There was a problem hiding this comment.
The derived version would trace documents even if they were Kept(false, doc). The idea is to implement poor-dev's weak references, that don't keep the documents alive.
39f3cea to
4d70ef6
Compare
|
r? @jdm |
|
☔ The latest upstream changes (presumably #13489) made this pull request unmergeable. Please resolve the merge conflicts. |
|
An IRC conversation with @jdm, @Ms2ger and @cbrewster: http://logs.glob.uno/?c=mozilla%23servo&s=4+Jan+2017&e=4+Jan+2017#c586779 TL;DR: this crash is probably caused by us not doing the window proxy to window mapping quite right, since we are generating a new |
|
@bors-servo try |
Implement discarding Document objects to reclaim space. <!-- Please describe your changes on the following line: --> This PR implements document discarding. Active documents are kept alive strongly, but inactive documents are only kept alive weakly. When a document is GCd, it is marked as discarded, and if it is every reactivated, a reload of the URL is triggered. Note that this PR is pretty aggressive about discarding, and can any inactive document (other than those being kept alive by other same-origin pipelines). We might want to damp it down a bit. Also note that this interacts with browser.html in that the reloading triggered by reactivating a document triggers mozbrowser events. To test this, I added a `-Zdiscard-inactive-documents` debug flag, which discards all inactive documents, even ones which are reachable through other same-origin pipelines. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #14262. - [X] These changes do not require tests because we should be able to use the existing tests with `-Zdiscard-inactive-documents`. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14312) <!-- Reviewable:end -->
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-gnu-dev, windows-msvc-dev |
|
This is ready to merge from my point of view. |
|
@bors-servo r=cbrewster cross fingers |
|
📌 Commit c14c431 has been approved by |
|
@bors-servo retry |
Implement discarding Document objects to reclaim space. <!-- Please describe your changes on the following line: --> This PR implements document discarding. Active documents are kept alive strongly, but inactive documents are only kept alive weakly. When a document is GCd, it is marked as discarded, and if it is every reactivated, a reload of the URL is triggered. Note that this PR is pretty aggressive about discarding, and can any inactive document (other than those being kept alive by other same-origin pipelines). We might want to damp it down a bit. Also note that this interacts with browser.html in that the reloading triggered by reactivating a document triggers mozbrowser events. To test this, I added a `-Zdiscard-inactive-documents` debug flag, which discards all inactive documents, even ones which are reachable through other same-origin pipelines. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #14262. - [X] These changes do not require tests because we should be able to use the existing tests with `-Zdiscard-inactive-documents`. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14312) <!-- Reviewable:end -->
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-gnu-dev, windows-msvc-dev |
This PR implements document discarding. Active documents are kept alive strongly, but inactive documents are only kept alive weakly. When a document is GCd, it is marked as discarded, and if it is every reactivated, a reload of the URL is triggered.
Note that this PR is pretty aggressive about discarding, and can any inactive document (other than those being kept alive by other same-origin pipelines). We might want to damp it down a bit.
Also note that this interacts with browser.html in that the reloading triggered by reactivating a document triggers mozbrowser events.
To test this, I added a
-Zdiscard-inactive-documentsdebug flag, which discards all inactive documents, even ones which are reachable through other same-origin pipelines../mach build -ddoes not report any errors./mach test-tidydoes not report any errors-Zdiscard-inactive-documents.This change is