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
Measure Arc<Locked<T>> fields properly. #18455
Measure Arc<Locked<T>> fields properly. #18455
Conversation
Currently when we measure various Arc<Locked<T>> fields we don't measure the T itself, but only the descendants of the T. This patch fixes this. This fix requires introducing a new trait, MallocUnconditionalShallowSizeOf, which is implemented for servo_arc::Arc. A similar trait, MallocConditionalShallowSizeOf, is also introduced, though it has no uses as yet.
Heads up! This PR modifies the following files:
|
This is for https://bugzilla.mozilla.org/show_bug.cgi?id=1398854. |
r? @jdm |
@bors-servo: r+ |
📌 Commit 779fbda has been approved by |
Measure Arc<Locked<T>> fields properly. Currently when we measure various Arc<Locked<T>> fields we don't measure the T itself, but only the descendants of the T. This patch fixes this. This fix requires introducing a new trait, MallocUnconditionalShallowSizeOf, which is implemented for servo_arc::Arc. A similar trait, MallocConditionalShallowSizeOf, is also introduced, though it has no uses as yet. <!-- Please describe your changes on the following line: --> --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because they are tested in Gecko. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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/18455) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
So I'd been hoping we would do something where you could call |
I tried that and it didn't work all that well. I created a new trait called
but sometimes you need to invoke
So you'd actually need two traits, or a single trait with two methods, or something. If we end up measuring enough of these |
So for what it's worth, I tried to implement my suggestion but using a single trait that is automatically implemented for Locked when T is MallocSizeOf, and ran into all sorts of issues with Rust's rules for traits. In particular, since MallocSizeOf is defined in one crate and MallocSizeOfWithGuard in another (so it can see the guard), Rust assumes that a single T can implement both. :( And if I put MallocSizeOfWithGuard in the malloc_size_of crate, then making it possible for it to take a guard is rocket science. :( |
I can believe it. One of the motivations for overhauling |
Looks like this merge brought some improvements: == Change summary for alert #9405 (as of September 12 2017 14:45 UTC) == Improvements: 4% Heap Unclassified summary windows10-64 opt 48,812,667.91 -> 46,759,664.87 For up to date results, see: https://treeherder.mozilla.org/perf.html#/alerts?id=9405 |
Currently when we measure various Arc<Locked> fields we don't measure the T
itself, but only the descendants of the T. This patch fixes this.
This fix requires introducing a new trait, MallocUnconditionalShallowSizeOf,
which is implemented for servo_arc::Arc. A similar trait,
MallocConditionalShallowSizeOf, is also introduced, though it has no uses as
yet.
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is