Use jemalloc and add endpoint to dump heap profiles #27

Open
Armael wants to merge 3 commits from Armael/tricot:jemalloc into main
Owner
No description provided.
Armael added 2 commits 2025-04-13 09:21:20 +00:00
Author
Owner

TODO: update the flake.nix & docker target (or get rid of it completely ?)

TODO: update the flake.nix & docker target (or get rid of it completely ?)
Owner

Ideally, I would really like we build the production container with Nix.
We can embed the necessary tooling quite easily if needed.

Finally, I got this script to quickly build a svg:

$ cat doflame.sh
set -euxo pipefail

mkdir -p tricot-heapdump
curl http://localhost:9334/hprof > tricot-heapdump/tricot.hprof
sudo docker run \
    --rm \
    -v `pwd`/tricot-heapdump:/tmp/tricot-heapdump \
    armael/tricot:jemalloc-3 \
    bash -c 'jeprof /usr/local/sbin/tricot /tmp/tricot-heapdump/tricot.hprof --collapse > /tmp/tricot-heapdump/tricot.perf'
perl -W ./flamegraph.pl ./tricot-heapdump/tricot.perf > ./tricot-heapdump/tricot.svg

It is intended to be run on the host machine, it's not perfect as you still need to:

  • manually download ./flamegraph.pl
  • manually run nix-shell -p perl before
  • the docker image is hardcoded (while it could be inferred from docker ps)
  • it does not support differential flamegraphs

I wanted to keep the .perf file as it can be injected in other, more powerful viewers than flamegraph.pl.

Feel free to improve it, or just copy/paste it at the end of the doc.

Let me know when we have settled upon the correct way to build a production container, and then let merge this work and plan a deployment!

Ideally, I would really like we build the production container with Nix. We can embed the necessary tooling quite easily if needed. Finally, I got this script to quickly build a `svg`: ```bash $ cat doflame.sh set -euxo pipefail mkdir -p tricot-heapdump curl http://localhost:9334/hprof > tricot-heapdump/tricot.hprof sudo docker run \ --rm \ -v `pwd`/tricot-heapdump:/tmp/tricot-heapdump \ armael/tricot:jemalloc-3 \ bash -c 'jeprof /usr/local/sbin/tricot /tmp/tricot-heapdump/tricot.hprof --collapse > /tmp/tricot-heapdump/tricot.perf' perl -W ./flamegraph.pl ./tricot-heapdump/tricot.perf > ./tricot-heapdump/tricot.svg ``` It is intended to be run on the host machine, it's not perfect as you still need to: - manually download `./flamegraph.pl` - manually run `nix-shell -p perl` before - the docker image is hardcoded (while it could be inferred from `docker ps`) - it does not support differential flamegraphs I wanted to keep the .perf file as it can be injected in other, more powerful viewers than `flamegraph.pl`. Feel free to improve it, or just copy/paste it at the end of the doc. Let me know when we have settled upon the correct way to build a production container, and then let merge this work and plan a deployment!
Armael closed this pull request 2025-04-13 13:43:12 +00:00
Armael reopened this pull request 2025-04-13 13:43:15 +00:00
Merge conflict checking is in progress. Try again in few moments.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u jemalloc:Armael-jemalloc
git checkout Armael-jemalloc

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout main
git merge --no-ff Armael-jemalloc
git checkout Armael-jemalloc
git rebase main
git checkout main
git merge --ff-only Armael-jemalloc
git checkout Armael-jemalloc
git rebase main
git checkout main
git merge --no-ff Armael-jemalloc
git checkout main
git merge --squash Armael-jemalloc
git checkout main
git merge --ff-only Armael-jemalloc
git checkout main
git merge Armael-jemalloc
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Deuxfleurs/tricot#27
No description provided.