facebook / memlab

A framework for finding JavaScript memory leaks and analyzing heap snapshots
https://facebook.github.io/memlab/
MIT License
4.3k stars 116 forks source link

Clarify the documentation about measure mode #116

Closed mrdulin closed 4 months ago

mrdulin commented 4 months ago

After reading the memlab measure documentation ten times, I still don't know what it is.

So I read the source code of MeasureMode.ts file.

Does that mean if run the scenario in measure mode, memlab will not:

When I run in measure mode, it seems memlab will run the scenario 10 times.

$ npx memlab measure --scenario tests/detached-DOM-elements/index.js
page-load[1.8MB](baseline)[s1] > action-on-page[2.1MB](target)[s2] > revert[2.3MB](final)[s3]

total time: 46.7s
page-load[1.8MB](baseline)[s1] > action-on-page[2.1MB](target)[s2] > revert[2.3MB](final)[s3]

total time: 46.5s
page-load[1.8MB](baseline)[s1] > action-on-page[2.1MB](target)[s2] > revert[2.3MB](final)[s3]

total time: 46.6s
page-load[1.8MB](baseline)[s1] > action-on-page[2.1MB](target)[s2] > revert[2.3MB](final)[s3]

total time: 46.6s
page-load[1.8MB](baseline)[s1] > action-on-page[2.1MB](target)[s2] > revert[2.3MB](final)[s3]

total time: 46.5s
page-load[1.8MB](baseline)[s1] > action-on-page[2.1MB](target)[s2] > revert[2.3MB](final)[s3]

total time: 46.6s
page-load[1.8MB](baseline)[s1] > action-on-page[2.1MB](target)[s2] > revert[2.3MB](final)[s3]

total time: 46.5s
page-load[1.8MB](baseline)[s1] > action-on-page[2.1MB](target)[s2] > revert[2.3MB](final)[s3]

total time: 46.5s
page-load[1.8MB](baseline)[s1] > action-on-page[2.1MB](target)[s2] > revert[2.3MB](final)[s3]

total time: 46.6s
page-load[1.8MB](baseline)[s1] > action-on-page[2.1MB](target)[s2] > revert[2.3MB](final)[s3]

total time: 46.6s

Please clarify the documentation, what's the measure mode and what are the usage scenarios for the measure mode?

JacksonGL commented 4 months ago

In some web apps, the heap size can show considerable variability across various runs. This fluctuation can often make it hard to understand the impact of memory leaks. The introduction of the measure mode aims to address this challenge by executing the same scenario repetitively, therefore getting multiple data points of JavaScript heap sizes. This can help understand if the heap size movements during specific runs come from memory-related issues or just noises.

mrdulin commented 4 months ago

@JacksonGL It's helpful. These explanations should be added to the documentation. If there is an example, that's better. Please consider it. Besides, can you open the GitHub repo discussion so we can ask questions there? Leave the GitHub issues for bug reports or feature requests.

JacksonGL commented 4 months ago

Those are good feedback, thanks. The GitHub repo discussion is now open.