javierhonduco / lightswitch

CPU profiler for Linux written in Rust
MIT License
7 stars 3 forks source link

Improve unwind information chunking and optimise unwind info #4

Closed javierhonduco closed 8 months ago

javierhonduco commented 8 months ago

Before we were splitting only on function boundaries, but this is not necessary, we can split anywhere as long as the end of function markers are in place for every single function that has a gap with the next function (sorted by PC), as well as the last function.

By doing this, we not only use the unwind shard space more efficiently, but also we support huge functions better, and have to do less work, while making the code more readable.

The cases that we have to handle (just showing PCs and generated chunk ranges):

Additionally, this commit also does some basic optimisations w.r.t. the unwind information, we remove redundant end of function markers as well as unwind rows that are repeated.

Test Plan

Tested for hours on my box and simulated worst case scenarios with very small unwind shards (few hundreds of items) without issues. Also wrote some exhaustive checker for these conditions, but the code isn't ready to be added yet, will submit a separate PR where all this logic is abstracted and the tests are added.