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

tcmalloc is used by default, even if it is not present #876

Closed
eschnett opened this issue Sep 24, 2013 · 2 comments
Closed

tcmalloc is used by default, even if it is not present #876

eschnett opened this issue Sep 24, 2013 · 2 comments
Assignees
Labels
category: CMake difficulty: easy Good issues for starting out with HPX development type: defect
Milestone

Comments

@eschnett
Copy link
Contributor

I am using HPX on Ubuntu 12.10.

It seems that HPX assumes that tcmalloc is available, and then complains when running cmake that it is not available. Instead, HPX should check whether tcmalloc is available, and simply not use it if it is not available.

These lines in CMakeLists.txt confirm my suspicion:
{{{
if(NOT HPX_MALLOC)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(HPX_MALLOC "TCMalloc")
else()
set(HPX_MALLOC "system")
endif()
endif()
}}}

My current work-around is to manually specify "system" as allocator. This should not be necessary.

On a side note: Although there is a "tcmalloc" package, this package only provides shared libraries and not the header files, i.e. it cannot be used to build programs. There is no other Ubuntu package that provides tcmalloc.h.

@zao
Copy link
Contributor

zao commented Sep 25, 2013

It is, impossibly to know as a mortal without apt-file or packages.ubuntu.com that the package happens to be libgoogle-perftools-dev on Ubuntu and gperftools-devel on Fedora. Other distros may have it in other places, so I don't know if mentioning it in the error would help or not. I would prefer some sort of human-readable diagnostic as to that using a non-system malloc is strongly recommended, and possibly a mention of the packages for Ubuntu/Fedora, or at the very least that it's typically bundled with Google perftools.

@eschnett
Copy link
Contributor Author

I first configured without specifying any allocator. The error message ("tcmalloc selected, but tcmalloc cannot be used" or similar) made it seems as if HPX had examined my system, found tcmalloc and thus selected it, and later found it to be unusable. I thus suspected a badly installed package on my system, and began to debug this.

Later, I found that HPX first selects tcmalloc, and then checks whether it is actually present. This seemed like a bug in HPX to me, thus this ticket. I set "-DHPX_MALLOC=system" as a work-around for a bug in HPX, and the performance implications were not clear to me at all.

Even later I find that this is all done on purpose. I recommend a few things:

(1) Add a comment to the code where tcmalloc is (unconditionally) selected for Linux, such as:

"On Linux, the system allocator has a bad performance for multi-threaded applications. We thus use tcmalloc by default. If tcmalloc is not present, this will fail. It is intentional that overriding this default requires an explicit "-DHPX_ALLOC=system" when configuring, so that the user knows about these performance implications.

(2) Be more clear in the error message. Unfortunately, you don't know at this point whether the user selected tcmalloc, or whether HPX selected tcmalloc. You want different error messages in both cases. If the user selected tcmalloc, then the current error message is fine. If HPX chose tcmalloc as default, then you want to output a message that (a) explains this choice of default, (b) explains the performance implications, and (c) describes the work-around if tcmalloc and friends are not available (-DHPX_ALLOC=system).

@ghost ghost assigned sithhell Sep 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: CMake difficulty: easy Good issues for starting out with HPX development type: defect
Projects
None yet
Development

No branches or pull requests

3 participants