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

Lots of unclassified heap memory #11559

Open
Ms2ger opened this issue Jun 2, 2016 · 12 comments
Open

Lots of unclassified heap memory #11559

Ms2ger opened this issue Jun 2, 2016 · 12 comments
Labels

Comments

@Ms2ger
Copy link
Contributor

@Ms2ger Ms2ger commented Jun 2, 2016

For example:

Begin memory reports
|
|  371.13 MiB -- explicit
|   17592186044408.38 MiB -- system-heap-unclassified
|     335.96 MiB -- jemalloc-heap-unclassified
|      39.66 MiB -- url(https://en.wikipedia.org/wiki/Main_Page)
|         15.75 MiB -- js
|             7.62 MiB -- malloc-heap
|             4.14 MiB -- non-heap
|             4.00 MiB -- gc-heap
|                3.34 MiB -- used
|                0.49 MiB -- decommitted
|                0.12 MiB -- admin
|                0.06 MiB -- unused
|         14.07 MiB -- layout-thread
|            13.73 MiB -- stylist
|             0.34 MiB -- display-list
|             0.00 MiB -- local-context
|          3.33 MiB -- dom-tree
|          1.09 MiB -- layout-worker-1-local-context
|          1.09 MiB -- layout-worker-2-local-context
|          1.09 MiB -- layout-worker-3-local-context
|          1.08 MiB -- layout-worker-5-local-context
|          1.08 MiB -- layout-worker-4-local-context
|          1.08 MiB -- layout-worker-0-local-context
|       3.12 MiB -- compositor-thread
|          2.34 MiB -- surface-map
|          0.78 MiB -- layer-tree
|
|  516.08 MiB -- resident-according-to-smaps
|     458.34 MiB -- anonymous (rw-p)
|      34.15 MiB -- /target/release/servo (r-xp)
|      12.49 MiB -- other
|       3.46 MiB -- /usr/lib/x86_64-linux-gnu/dri/i965_dri.so (r-xp)
|       2.21 MiB -- /target/release/servo (r--p)
|       1.50 MiB -- /lib/x86_64-linux-gnu/libc-2.19.so (r-xp)
|       1.40 MiB -- /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (r-xp)
|       0.73 MiB -- /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0 (r-xp)
|       0.72 MiB -- /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19 (r-xp)
|       0.55 MiB -- /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0 (r-xp)
|       0.53 MiB -- /usr/lib/x86_64-linux-gnu/libfreetype.so.6.11.1 (r-xp)
|
|  373.42 MiB -- jemalloc-heap-active
|  359.86 MiB -- jemalloc-heap-allocated
|  667.00 MiB -- jemalloc-heap-mapped
|  512.55 MiB -- resident
|    0.00 MiB -- system-heap-allocated
| 1037.36 MiB -- vsize
|
End memory reports

@froydnj @nnethercote do you know if we could get DMD set up for Servo?

@Ms2ger Ms2ger added the I-perf-bloat label Jun 2, 2016
@nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Jun 2, 2016

|  371.13 MiB -- explicit
|   17592186044408.38 MiB -- system-heap-unclassified
|     335.96 MiB -- jemalloc-heap-unclassified

Something's clearly gone wrong there. Each tree's sub-trees are supposed to add up, and 17592186044408.38 MiB is clearly bogus.

I wanted to do DMD for Servo but never got around to it. The hard part was wrapping the heap allocator. I talked with @acrichton about the required machinery for this, which is theoretically in place, but I never tried it out in earnest. DMD also requires that you can get backtraces (to store) on each allocation, and that wasn't in place when I was looking at it, though it might be now.

@jdm
Copy link
Member

@jdm jdm commented Jun 2, 2016

We have the ability to grab backtraces while running Rust code: Backtrace::new.

@nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Jun 2, 2016

Oh, the other complication for DMD with Servo is that you have two malloc heaps -- the system heap, used by all the C/C++ libraries that Servo uses, and the jemalloc heap used by Rust. I never worked out how to deal with that. This problem doesn't occur in Firefox because all heap allocations in Firefox get routed through jemalloc.

@nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Jun 2, 2016

We have the ability to grab backtraces while running Rust code: Backtrace::new.

Lovely! Looks like a nice design.

@jdm
Copy link
Member

@jdm jdm commented Jan 3, 2017

Given https://github.com/rust-lang/rfcs/blob/master/text/1183-swap-out-jemalloc.md and rust-lang/rust#27389, it looks like we might be getting close to being able to create a DMD tool for Servo.

@jdm
Copy link
Member

@jdm jdm commented Jan 17, 2017

I have Servo building with a custom jemalloc-based allocator with some small changes. In particular, we need to use permanent forks of the libc and memchr crates that disable their attempts to re-export the std crate. This fork of japaric's extraction of rustc's jemalloc allocator allows modifying the allocator functions to add custom behaviour (I added a puts call every time an allocation occurred in a local clone).

@jdm
Copy link
Member

@jdm jdm commented Jan 17, 2017

Next step is to figure out the parts of http://dxr.mozilla.org/mozilla-central/source/memory/replace/dmd/DMD.cpp that need to be ported.

@nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Jan 17, 2017

rust-lang/rfcs#916 describes in detail my previous attempt at DMD for Servo. RFC 1183 may have changed things significantly -- I haven't looked closely at it -- but that issue would still be a good starting point for anyone wanting to work on this.

@nox
Copy link
Member

@nox nox commented Jan 19, 2017

For anyone reading this and being confused, DMD stands for "dark matter detector".

@nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Jan 19, 2017

@nox
Copy link
Member

@nox nox commented Oct 1, 2017

@nnethercote How is this going?

@nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Oct 2, 2017

I am not working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.