tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
11.27k stars 286 forks source link

add in-process heap profiler #1503

Closed MarinPostma closed 4 months ago

MarinPostma commented 4 months ago

This PR introduces a in-process heap profiler, using hipptrack.

The profiler is enabled by sending a request to the admin api:

echo '{}' | POST /profile/heap/enable

when enabled, hipptrack will start recording all allocation. The name of the profile is returned by the call to the endpoint.

to stop recording and download the profile:

POST /profile/heap/disable/:profile-id

this will download a tarball of the profile. The profile can then be analyzed using hipptrack:

POST /profile/heap/disable/hip-84397533 > profile.tar
tar xvf profile.tar
hipptrack hip-84397533 profile.db

sqlite3 profile.db

to remove the profile file from the server:

DELETE /profile/heap/:profile-id