danielealbano / cachegrand

cachegrand - a modern data ingestion, processing and serving platform built for today's hardware
BSD 3-Clause "New" or "Revised" License
975 stars 34 forks source link

Add function/line allocation tracking and support release mode in FFMA #345

Closed danielealbano closed 1 year ago

danielealbano commented 1 year ago

This PR improves the memory allocation / freeing tracking in FFMA and add its support to the release mode.

The implementation is fairly simple, it doesn't store entire entire stack trace but just a pointer to the function name and the line number adding a total of 12 bytes to each ffma_slot_t entry.

The tracking is done leveraging FUNCTION and LINE using some defines to wrap the underlying invocations.

At the end cachegrand's execution now if there are memory leaks these are printed out.

Also FFMA is not freed anymore as it doesn't make sense to free it, it's the memory allocator and keeping around the basic data structure allows better tracking of the memory leaks and avoid issues with threads trying to write to freed FFMA instances (which is bad :)).

This new feature has allowed to discover some memory leaks that are going to be fixed with ad-hoc PRs.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 46.94% and project coverage change: -0.38 :warning:

Comparison is base (ec3b624) 77.04% compared to head (8491ece) 76.66%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #345 +/- ## ========================================== - Coverage 77.04% 76.66% -0.38% ========================================== Files 179 179 Lines 12421 12450 +29 ========================================== - Hits 9569 9544 -25 - Misses 2852 2906 +54 ``` | Flag | Coverage Δ | | |---|---|---| | unittests | `76.66% <46.94%> (-0.38%)` | :arrow_down: | 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=Daniele+Salvatore+Albano#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://codecov.io/gh/danielealbano/cachegrand/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano) | Coverage Δ | | |---|---|---| | [src/memory\_allocator/ffma\_thread\_cache.h](https://codecov.io/gh/danielealbano/cachegrand/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano#diff-c3JjL21lbW9yeV9hbGxvY2F0b3IvZmZtYV90aHJlYWRfY2FjaGUuaA==) | `100.00% <ø> (ø)` | | | [src/memory\_allocator/ffma.c](https://codecov.io/gh/danielealbano/cachegrand/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano#diff-c3JjL21lbW9yeV9hbGxvY2F0b3IvZmZtYS5j) | `64.71% <25.71%> (-31.53%)` | :arrow_down: | | [src/memory\_allocator/ffma.h](https://codecov.io/gh/danielealbano/cachegrand/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano#diff-c3JjL21lbW9yeV9hbGxvY2F0b3IvZmZtYS5o) | `98.23% <100.00%> (+0.06%)` | :arrow_up: | | [src/memory\_allocator/ffma\_thread\_cache.c](https://codecov.io/gh/danielealbano/cachegrand/pull/345?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano#diff-c3JjL21lbW9yeV9hbGxvY2F0b3IvZmZtYV90aHJlYWRfY2FjaGUuYw==) | `95.65% <100.00%> (-0.64%)` | :arrow_down: | ... and [5 files with indirect coverage changes](https://codecov.io/gh/danielealbano/cachegrand/pull/345/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano) Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.