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

Allow to disable tbbmalloc (oneTBB) #326

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Lastique
Copy link
Contributor

@Lastique Lastique commented Dec 28, 2020

This is an updated version of #149 which targets the reworked code base of oneTBB 2021.1.1.

The patch adds TBB_USE_MALLOC environment variable to force using system allocator.

By setting TBB_USE_MALLOC environment variable to 1 the user can disable scalable allocator from tbbmalloc and use system allocator through malloc/posix_memalign/free API. There are other, more performant memory allocators, like tcmalloc for example, which the user might want to use instead of tbbmalloc. Also, using the system allocator can be useful with memory debugging and profiling tools, like valgrind. Such tools usually provide their own implementations of memory allocation functions, and we want those functions to be used by TBB.

The original PR #149 contains some benchmarks and rationale as to why we prefer an environment variable as a way to disable tbbmalloc.

By setting TBB_USE_MALLOC environment variable to 1 the user can disable
scalable allocator from tbbmalloc and use system allocator through
malloc/posix_memalign/free API. There are other, more performant memory
allocators, like tcmalloc for example, which the user might want to use
instead of tbbmalloc. Also, using the system allocator can be useful with
memory debugging and profiling tools, like valgrind. Such tools usually
provide their own implementations of memory allocation functions, and
we want those functions to be used by TBB.

Signed-off-by: Andrey Semashev <andrey.semashev@gmail.com>
@Lastique Lastique force-pushed the disable_tbbmalloc_onetbb_2021 branch from e9ed85c to ca7648e Compare November 25, 2021 17:20
@Lastique Lastique changed the base branch from onetbb_2021 to master November 25, 2021 17:20
@Lastique Lastique changed the title Allow to disable tbbmalloc, use posix_memalign (oneTBB) Allow to disable tbbmalloc (oneTBB) Nov 25, 2021
@Lastique
Copy link
Contributor Author

The patch to enable support for memalign, posix_memalign, etc. has been extracted into a separate PR #671.

Comment on lines +120 to +121
if (!GetBoolEnvironmentVariable("TBB_USE_MALLOC"))
success = dynamic_link(MALLOCLIB_NAME, MallocLinkTable, 4);
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you considered an approach to extend global_control functionality? Usually, we try to avoid configuration via environment variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the rationale and discussion about global_control is in the previous version of this PR: #149. The short version is that we want to ensure that tbbmalloc is not enabled if TBB is used somewhere during global initialization of the program, and we want to propagate that setting to child processes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants