Skip to content

Replace complicated memory pool allocator with plain malloc()#997

Merged
arogge merged 10 commits intobareos:masterfrom
arogge:dev/arogge/master/fix-poolmem
Dec 2, 2021
Merged

Replace complicated memory pool allocator with plain malloc()#997
arogge merged 10 commits intobareos:masterfrom
arogge:dev/arogge/master/fix-poolmem

Conversation

@arogge
Copy link
Member

@arogge arogge commented Nov 24, 2021

This PR changes the pool memory implementation to not be pooled anymore.
As it turned out the operating system is a lot better at managing memory than our 20 year old pooling implementation was.
The now non-functional management functions have been removed from the interface and a lot of redundant implementation code has been merged.
We also adds a benchmark and tests for the new implementation.
Furthermore a use-after-free bug was fixed.

Thank you for contributing to the Bareos Project!

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

General
  • PR name is meaningful
  • Purpose of the PR is understood
  • Separate commit for this PR in the CHANGELOG.md, PR number referenced is same
  • Commit descriptions are understandable and well formatted
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
  • bareos-check-sources --since-merge does not report any problems
  • git status should not report modifications in the source tree after building and testing
Tests
  • Decision taken that a system- or unittest is required
  • Testname matches exactly what is being tested
  • Output of the test leads quickly to the origin of the fault

@arogge arogge force-pushed the dev/arogge/master/fix-poolmem branch 3 times, most recently from 46f6454 to b3ce827 Compare November 25, 2021 21:10
@arogge arogge changed the title Fix pool memory performance issues Replace complicated memory pool allocator with plain malloc() Nov 26, 2021
@arogge arogge force-pushed the dev/arogge/master/fix-poolmem branch from 02e31e9 to 24e84ad Compare November 26, 2021 16:42
@arogge arogge requested a review from pstorz November 26, 2021 16:45
@arogge arogge force-pushed the dev/arogge/master/fix-poolmem branch from 24e84ad to fd61496 Compare November 26, 2021 16:50
@pstorz pstorz force-pushed the dev/arogge/master/fix-poolmem branch from fd61496 to 1520853 Compare November 26, 2021 17:48
This benchmark shows the performance impact when using poolmem. As a
comparison we benchmark against std::string.
Historically, Bareos had pooled memory. However, nowadays operating
systems are a lot better at handling memory than we are, so this patch
removes the memory pooling and just calls malloc() and free() everytime
memory is requested or returned.
This patch removes unused members from struct abufhead and also removes
the pool management functions that are now a no-operation (and all calls
to them).
Previously, poolmem used a lot of hard-to-read c-style casts. This patch
consolidates pointer-arithmetic as much as possible and tries to avoid
duplicated code.
While changing the code, we also changed the interface a little, all the
allocation/deallocation-related functions are now marked noexcept.
This patch adds a test-suite for all functionality in mem_pool.h and
mem_pool.cc.
@arogge arogge force-pushed the dev/arogge/master/fix-poolmem branch from 1520853 to 92a44de Compare December 2, 2021 12:58
@arogge arogge requested a review from pstorz December 2, 2021 12:58
Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good work!

and disable clang-format in char* encode_mode()
This patch removes redundant variants of the same function bodies by
simply calling another function with the same functionality where
possible.
@arogge arogge force-pushed the dev/arogge/master/fix-poolmem branch from fbf0831 to ec67010 Compare December 2, 2021 13:40
@arogge arogge merged commit 24eca5b into bareos:master Dec 2, 2021
@arogge arogge deleted the dev/arogge/master/fix-poolmem branch December 2, 2021 13:43
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.

2 participants

Comments