Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement discarding Document objects to reclaim space. #14312
Conversation
highfive
commented
Nov 21, 2016
highfive
commented
Nov 21, 2016
|
Maybe the name of that flag needs unsafe in it? It seems a little confusingly worded as is. |
|
|
|
@metajack: yes, that option name isn't my best-ever writing. |
e398d45
to
376f059
|
|
376f059
to
39f3cea
|
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. |
| /// The state that a document managed by this script thread could be in. | ||
| #[must_root] | ||
| enum DocumentState { | ||
| Kept(bool, JS<Document>), |
This comment has been minimized.
This comment has been minimized.
emilio
Nov 26, 2016
Member
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.
This comment has been minimized.
This comment has been minimized.
| fn trace(&self, trc: *mut JSTracer) { | ||
| // Note: we only trace thawed documents. | ||
| if let DocumentState::Kept(true, ref doc) = *self { | ||
| doc.trace(trc); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
asajeffrey
Nov 28, 2016
Author
Member
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
|
r? @jdm |
|
|
|
@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 -->
|
|
|
This is ready to merge from my point of view. |
|
@bors-servo r=cbrewster cross fingers |
|
|
|
@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 -->
|
|
…when-discarding, r=cbrewster Index the session past correctly when discarding. <!-- Please describe your changes on the following line: --> Oops, indexed from the wrong end when discarding documents in #14312. --- <!-- 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 do not require tests because we're not testing document discarding <!-- 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/14860) <!-- Reviewable:end -->
…when-discarding, r=cbrewster Index the session past correctly when discarding. <!-- Please describe your changes on the following line: --> Oops, indexed from the wrong end when discarding documents in #14312. --- <!-- 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 do not require tests because we're not testing document discarding <!-- 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/14860) <!-- Reviewable:end -->
…when-discarding, r=cbrewster Index the session past correctly when discarding. <!-- Please describe your changes on the following line: --> Oops, indexed from the wrong end when discarding documents in #14312. --- <!-- 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 do not require tests because we're not testing document discarding <!-- 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/14860) <!-- Reviewable:end -->
asajeffrey commentedNov 21, 2016
•
edited by larsbergstrom
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