Skip to content

experimental enable jemalloc API for FreeBSD too.#1294

Closed
devnexen wants to merge 1 commit into
facebook:masterfrom
devnexen:jemalloc_fbsd
Closed

experimental enable jemalloc API for FreeBSD too.#1294
devnexen wants to merge 1 commit into
facebook:masterfrom
devnexen:jemalloc_fbsd

Conversation

@devnexen

Copy link
Copy Markdown
Contributor

Contrary to other systems, jemalloc is part of the FreeBSD's libc.
As such APIs are directly exposed. Enabling super pages
as well, supporting same page size.

#define MADV_HUGEPAGE 0

#if !defined(JEMALLOC_VERSION_MAJOR) || (JEMALLOC_VERSION_MAJOR < 5)
#if (!defined(JEMALLOC_VERSION_MAJOR) || (JEMALLOC_VERSION_MAJOR < 5))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This bit is not related.

Comment thread CMake/FollyConfigChecks.cmake Outdated
Comment on lines +23 to +27
if (NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
CHECK_INCLUDE_FILE_CXX(jemalloc/jemalloc.h FOLLY_USE_JEMALLOC)
else()
CHECK_INCLUDE_FILE_CXX(malloc_np.h FOLLY_USE_JEMALLOC)
endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should switch the conditions around. That way, further conditions can easily be added as necessary.

if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
  ...
else()
  ...
endif()
Comment on lines +25 to +29
#if !defined(__FreeBSD__)
#include <jemalloc/jemalloc.h>
#if (JEMALLOC_VERSION_MAJOR >= 5)
#else
#include <malloc_np.h>
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Likewise.

#else
#include <malloc_np.h>
#endif
#if defined(__FreeBSD__) || (JEMALLOC_VERSION_MAJOR >= 5)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need the __FreeBSD__ check here? Does jemalloc on FreeBSD not define JEMALLOC_VERSION_MAJOR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nope. they keep all "close to the vest". fair enough for the rest.

Comment thread folly/portability/Malloc.h Outdated
#endif
// JEMalloc provides it's own implementation of
// malloc_usable_size, and that's what we should be using.
#ifndef __FreeBSD__

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I prefer #if !defined(...), since that way it is easier to add clauses to the condition as necessary.

#if defined(FOLLY_USE_JEMALLOC) && !FOLLY_SANITIZE

#include <folly/portability/SysMman.h>
#if !defined(__FreeBSD__)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same.

Comment thread folly/memory/Malloc.h Outdated
*/
#if (defined(USE_JEMALLOC) || defined(FOLLY_USE_JEMALLOC)) && !FOLLY_SANITIZE
// We have JEMalloc, so use it.
#if !defined(__FreeBSD__)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same.

Comment thread folly/portability/Malloc.h Outdated
#endif
// JEMalloc provides it's own implementation of
// malloc_usable_size, and that's what we should be using.
#if !defined(__FreeBSD__)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same.

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@yfeldblum has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@yfeldblum

Copy link
Copy Markdown
Contributor

There was some duplication here, the root cause of which I address in d054e34 (on master). Please rebase past that and resolve conflicts?

Contrary to other systems, jemalloc is part of the FreeBSD's libc.
As such APIs are directly exposed. Enabling super pages
as well, supporting same page size.

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@yfeldblum has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@yfeldblum merged this pull request in 647ad23.

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

3 participants