mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
8c4cf3102d
Add a tool to gather and visualize memory data for a running crosvm instance. BUG=b:290331222 TEST=Run the tool for ARCVM/Borealis Change-Id: Iffb3c60dfab6bc9e21979ef3ce367cad0e8b0514 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4712086 Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org> Reviewed-by: Junichi Uekawa <uekawa@chromium.org> Commit-Queue: Junichi Uekawa <uekawa@chromium.org> |
||
---|---|---|
.. | ||
src | ||
Cargo.lock | ||
Cargo.toml | ||
plot.py | ||
README.md | ||
requirements.txt | ||
sample.png |
memstats chart
Gather and visualize memory information of each crosvm process, the guest and virtio-balllon for a running crosvm instance.
This tool only supports Linux enviroments.
Usage
Install dependencies
We need to install some Python libraries for visualization.
$ pip install -r ./requirements.txt
Build
Build the tool with cargo and copy the binary to the device if necessary.
$ cd crosvm/tools/contrib/memstats_chart/
$ cargo build --release
# (optional) If crosvm is running on another machine, copy the binary to the machine.
$ scp ./target/release/memstats $DUT:/your/favorite/directory/
If you want to run the binary on aarch64 while your workstation is x86, dev_container
is useful.
$ ${CROSVM_PATH}/tools/dev_container
(container)$ cd tools/contrib/memstats_chart
(container)$ cargo build --target aarch64-unknown-linux-gnu
(container)$ cp /scratch/cargo_target/aarch64-unknown-linux-gnu/debug/memstats
Collect data
Run the binary. Note that this tool is assuming that only one crosvm is running on the system. If there are multiple crosvm instances running, this tool will abort.
$ ./memstats --output memory-data.json
# Press Ctrl-C to stop collecting data
Visualize the data
Visualize the obtained JSON file with plot.py
.
$ python3 plot.py -i ./memory-data.json
./memory-data.html is written
$ google-chrome ./memory-data.html