bloomberg / memray

Memray is a memory profiler for Python
https://bloomberg.github.io/memray/
Apache License 2.0
13.17k stars 392 forks source link

Avoid creating more `backtrace_state*` than needed #473

Closed godlygeek closed 12 months ago

godlygeek commented 12 months ago

libbacktrace gives us no way to free a backtrace_state* once it's been created, so it's in our best interest to create as few of them as possible. Rather than having one cache of backtrace_state* per opened capture file, have a global cache of backtrace_state* (protected by a global mutex).

Closes: #472

codecov-commenter commented 12 months ago

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (98032ae) 91.99% compared to head (b85885c) 91.96%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #473 +/- ## ========================================== - Coverage 91.99% 91.96% -0.03% ========================================== Files 91 91 Lines 10803 10807 +4 Branches 1485 1485 ========================================== + Hits 9938 9939 +1 - Misses 863 866 +3 Partials 2 2 ``` | [Flag](https://app.codecov.io/gh/bloomberg/memray/pull/473/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg) | Coverage Δ | | |---|---|---| | [cpp](https://app.codecov.io/gh/bloomberg/memray/pull/473/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg) | `85.22% <90.74%> (-0.07%)` | :arrow_down: | | [python_and_cython](https://app.codecov.io/gh/bloomberg/memray/pull/473/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg) | `95.41% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/bloomberg/memray/pull/473?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg) | Coverage Δ | | |---|---|---| | [src/memray/\_memray/native\_resolver.h](https://app.codecov.io/gh/bloomberg/memray/pull/473?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg#diff-c3JjL21lbXJheS9fbWVtcmF5L25hdGl2ZV9yZXNvbHZlci5o) | `100.00% <100.00%> (ø)` | | | [src/memray/\_memray/native\_resolver.cpp](https://app.codecov.io/gh/bloomberg/memray/pull/473?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg#diff-c3JjL21lbXJheS9fbWVtcmF5L25hdGl2ZV9yZXNvbHZlci5jcHA=) | `81.06% <90.38%> (+1.23%)` | :arrow_up: | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/bloomberg/memray/pull/473/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.