Add GC heap developer tools for profiling and debugging

Abierto
#14,615 0 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
12/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
rust, wasm

Línea de trabajo

The issue names no source files or tests, so start by deciding scope: it has two separate parts, allocation-site sampling for profiling and heap-graph serialization for debugging. Read the linked fast-bernoulli crate and the Firefox Profiler and DevTools memory formats it proposes reusing. Done means a maintainer-agreed design, not a patch, so raise the format and sampling questions in the thread first.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement wasm-proposal:gc
For profiling

"Why is the program spending so much time in GC?" aka "where am I allocating all this stuff that is forcing GC?"

We should support sampling the stack on GC allocation. These samples can then be coalesced and displayed as a tree or flamegraph, similar to how time/cpu profiling is often displayed.

Not all GC allocations are equal: a cons cell is cheaper than a large array. So we want to check whether we should sample the stack per byte allocated and not per object allocated. We can use https://github.com/fitzgen/fast-bernoulli for this.

The firefox profiler supports allocation stack sampling, so I presume its data format does as well, and we could maybe reuse it for this here too.

For debugging

"Why is my GC heap usage so high?"

"What is keeping this large object alive?"

We should be able to serialize the GC heap into an on-disk format that we can then run analyses on to answer questions like:

  1. What are the objects taking up the most space in the GC heap?
  2. Why is this object, that I would have expected not to be in use anymore and reclaimed by the collector, still live in the GC heap?
  3. What is unintentionally retained (i.e. the GC version of "leaked") after the program does X?

(1) is best answered by (a) a dominator tree analysis and ranking an object by its retained size (as opposed to its self size), and (b) taking a census and categorizing objects by type or allocation site and displaying them as a treemap.

(2) is best answered by an analysis that reports the N shortest paths from a GC root to the object of interest.

(3) is best answered by diffing heap snapshots before and after repeatedly doing X.

I don't know if there is any popular tool that has a stable heap snapshot format where we can just serialize our heap graph into that format and then it runs these analyses for us and displays their results in a UI for us.

I built the Firefox DevTools's memory tool, and we could reuse its protobuf heap snapshot serialization format to allow importing our heap snapshots into its UI, but this wouldn't be quite as slick as the firefox profiler experience, because the memory tool doesn't exist as a standalone web page, you'd have to open up the firefox devtools and manually import the snapshot(s).

Maybe there is a standalone alternative I'm not aware of?

Lenguaje dominante
Rust
Estrellas
18.9k
Forks
2k
Merge medio
1 d 6 h
PR fusionados (30 d)
238

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de bytecodealliance/wasmtime

Todos los issues de bytecodealliance/wasmtime

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.