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

Replace all uses of the `heapsize` crate with `malloc_size_of`. #18938

Merged
merged 1 commit into from Oct 18, 2017

Conversation

Projects
None yet
6 participants
@nnethercote
Copy link
Contributor

commented Oct 18, 2017

Servo currently uses heapsize, but Stylo/Gecko use malloc_size_of.
malloc_size_of is better -- it handles various cases that heapsize does not
-- so this patch changes Servo to use malloc_size_of.

This patch makes the following changes to the malloc_size_of crate.

  • Adds MallocSizeOf trait implementations for numerous types, some built-in
    (e.g. VecDeque), some external and Servo-only (e.g. string_cache).

  • Makes enclosing_size_of_op optional, because vanilla jemalloc doesn't
    support that operation.

  • For HashSet/HashMap, falls back to a computed estimate when
    enclosing_size_of_op isn't available.

  • Adds an extern "C" malloc_size_of function that does the actual heap
    measurement; this is based on the same functions from the heapsize crate.

This patch makes the following changes elsewhere.

  • Converts all the uses of heapsize to instead use malloc_size_of.

  • Disables the "heapsize"/"heap_size" feature for the external crates that
    provide it.

  • Removes the HeapSizeOf implementation from hashglobe.

  • Adds ignore annotations to a few Rc/Arc, because malloc_size_of
    doesn't derive those types, unlike heapsize.


  • There are tests for these changes OR
  • These changes do not require tests because testing is on the Gecko side.

This change is Reviewable

@highfive

This comment has been minimized.

Copy link

commented Oct 18, 2017

Heads up! This PR modifies the following files:

  • @bholley: ports/geckolib/glue.rs, components/style/values/generics/flex.rs, components/style/stylesheet_set.rs, components/style/rule_tree/mod.rs, components/style/values/specified/length.rs and 86 more
  • @jgraham: components/webdriver_server/Cargo.toml
  • @canaltinova: components/style/values/generics/flex.rs, components/style/stylesheet_set.rs, components/style/rule_tree/mod.rs, components/style/values/specified/length.rs, components/style/stylesheets/origin.rs and 83 more
  • @emilio: ports/geckolib/glue.rs, components/script/dom/webglframebuffer.rs, components/style/values/generics/flex.rs, components/style/stylesheet_set.rs, components/style/rule_tree/mod.rs and 97 more
  • @fitzgen: components/script/dom/request.rs, components/script/dom/xmlhttprequest.rs, components/script/dom/webglframebuffer.rs, components/script/dom/crypto.rs, components/devtools_traits/Cargo.toml and 127 more
  • @KiChjang: components/script/dom/request.rs, components/script/dom/xmlhttprequest.rs, components/script/dom/webglframebuffer.rs, components/script/dom/crypto.rs, components/script/dom/vrdisplaycapabilities.rs and 136 more
  • @asajeffrey: components/webdriver_server/Cargo.toml
  • @paulrouget: components/servo_arc/Cargo.toml, components/servo_arc/lib.rs
@highfive

This comment has been minimized.

Copy link

commented Oct 18, 2017

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
@nnethercote

This comment has been minimized.

Copy link
Contributor Author

commented Oct 18, 2017

r? @SimonSapin

This fixes all the issues identified in #18920:

  • VecDeque
  • Windows kernel32-sys errors
  • size_of_is_0! has been renamed as malloc_size_of_is_0!
  • The out-of-date comment about Rc has been removed.
@SimonSapin

This comment has been minimized.

Copy link
Member

commented Oct 18, 2017

Looks great, thanks you!

@bors-servo r+


Reviewed 269 of 269 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@bors-servo

This comment has been minimized.

Copy link
Contributor

commented Oct 18, 2017

📌 Commit 4917b40 has been approved by SimonSapin

@jdm

This comment has been minimized.

Copy link
Member

commented Oct 18, 2017

@bors-servo r-
Appveyor is failing

@SimonSapin

This comment has been minimized.

Copy link
Member

commented Oct 18, 2017

extern crate malloc_size_of; in components/gfx/lib.rs should be #[cfg_attr(target_os = "windows", macro_use)] extern crate malloc_size_of;

Replace all uses of the `heapsize` crate with `malloc_size_of`.
Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`.
`malloc_size_of` is better -- it handles various cases that `heapsize` does not
-- so this patch changes Servo to use `malloc_size_of`.

This patch makes the following changes to the `malloc_size_of` crate.

- Adds `MallocSizeOf` trait implementations for numerous types, some built-in
  (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`).

- Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't
  support that operation.

- For `HashSet`/`HashMap`, falls back to a computed estimate when
  `enclosing_size_of_op` isn't available.

- Adds an extern "C" `malloc_size_of` function that does the actual heap
  measurement; this is based on the same functions from the `heapsize` crate.

This patch makes the following changes elsewhere.

- Converts all the uses of `heapsize` to instead use `malloc_size_of`.

- Disables the "heapsize"/"heap_size" feature for the external crates that
  provide it.

- Removes the `HeapSizeOf` implementation from `hashglobe`.

- Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of`
  doesn't derive those types, unlike `heapsize`.

@nnethercote nnethercote force-pushed the nnethercote:bug-1409255 branch from 4917b40 to 4506f0d Oct 18, 2017

@SimonSapin

This comment has been minimized.

Copy link
Member

commented Oct 18, 2017

@bors-servo r+

BTW @nnethercote, github doesn’t notify when an amended commit is pushed to a PR, I only saw your update by change. You may want to comment after pushing, to let the reviewer know.


Reviewed 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@bors-servo

This comment has been minimized.

Copy link
Contributor

commented Oct 18, 2017

📌 Commit 4506f0d has been approved by SimonSapin

@SimonSapin

This comment has been minimized.

Copy link
Member

commented Oct 18, 2017

@bors-servo p=1 (I have another PR on top of this.)

@bors-servo

This comment has been minimized.

Copy link
Contributor

commented Oct 18, 2017

⌛️ Testing commit 4506f0d with merge 4c538b6...

bors-servo added a commit that referenced this pull request Oct 18, 2017

Auto merge of #18938 - nnethercote:bug-1409255, r=SimonSapin
Replace all uses of the `heapsize` crate with `malloc_size_of`.

Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`.
`malloc_size_of` is better -- it handles various cases that `heapsize` does not
-- so this patch changes Servo to use `malloc_size_of`.

This patch makes the following changes to the `malloc_size_of` crate.

- Adds `MallocSizeOf` trait implementations for numerous types, some built-in
  (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`).

- Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't
  support that operation.

- For `HashSet`/`HashMap`, falls back to a computed estimate when
  `enclosing_size_of_op` isn't available.

- Adds an extern "C" `malloc_size_of` function that does the actual heap
  measurement; this is based on the same functions from the `heapsize` crate.

This patch makes the following changes elsewhere.

- Converts all the uses of `heapsize` to instead use `malloc_size_of`.

- Disables the "heapsize"/"heap_size" feature for the external crates that
  provide it.

- Removes the `HeapSizeOf` implementation from `hashglobe`.

- Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of`
  doesn't derive those types, unlike `heapsize`.

<!-- 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 https://bugzilla.mozilla.org/show_bug.cgi?id=1409255

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because testing is on the Gecko side.

<!-- 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/18938)
<!-- Reviewable:end -->
@bors-servo

This comment has been minimized.

Copy link
Contributor

commented Oct 18, 2017

@bors-servo bors-servo merged commit 4506f0d into servo:master Oct 18, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@nnethercote nnethercote deleted the nnethercote:bug-1409255 branch Oct 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.