Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid creating more backtrace_state* than needed #473

Merged
merged 2 commits into from
Oct 2, 2023

Conversation

godlygeek
Copy link
Contributor

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

Rather than having a `StringStorage` class which exposes a custom
identifier used as a token for resolving an interned string, expose an
`InternedString` type directly constructible from a `std::string`. This
type handles the interning automatically, and using this type in
signatures allows us to encode whether a particular function needs to be
called with an interned string or could be called with any string.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@godlygeek godlygeek self-assigned this Oct 2, 2023
@codecov-commenter
Copy link

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
@@            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 Coverage Δ
cpp 85.22% <90.74%> (-0.07%) ⬇️
python_and_cython 95.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/memray/_memray/native_resolver.h 100.00% <100.00%> (ø)
src/memray/_memray/native_resolver.cpp 81.06% <90.38%> (+1.23%) ⬆️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

`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).

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@pablogsal pablogsal merged commit 1d5ffd5 into bloomberg:main Oct 2, 2023
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memray leaks native backtrace state
3 participants