-
Notifications
You must be signed in to change notification settings - Fork 909
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
new(cmake,ci): added support for using jemalloc allocator instead of glibc one #3406
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6bc348b
new(cmake,ci): added support for using jemalloc allocator instead of …
FedeDP f93e696
new(cmake,userspace): expose jemalloc stats in stats writer and prome…
FedeDP 1709839
fix(cmake): fixed jemalloc from system.
FedeDP e250e84
chore(ci): drop jemalloc from ASAN builds.
FedeDP 7fe39a3
chore(cmake): add a warning when using both jemalloc and asan.
FedeDP b8db7e5
update(cmake): bump jemalloc asan warning message
FedeDP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Copyright (C) 2024 The Falco Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
# in compliance with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License | ||
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
# or implied. See the License for the specific language governing permissions and limitations under | ||
# the License. | ||
# | ||
|
||
option(USE_BUNDLED_JEMALLOC "Use bundled jemalloc allocator" ${USE_BUNDLED_DEPS}) | ||
|
||
if(JEMALLOC_INCLUDE) | ||
# we already have JEMALLOC | ||
elseif(NOT USE_BUNDLED_JEMALLOC) | ||
find_path(JEMALLOC_INCLUDE jemalloc/jemalloc.h) | ||
set(JEMALLOC_INCLUDE ${JEMALLOC_INCLUDE}/jemalloc) | ||
if(BUILD_SHARED_LIBS) | ||
set(JEMALLOC_LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) | ||
else() | ||
set(JEMALLOC_LIB_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
endif() | ||
find_library(JEMALLOC_LIB NAMES libjemalloc${JEMALLOC_LIB_SUFFIX}) | ||
if(JEMALLOC_LIB) | ||
message(STATUS "Found JEMALLOC: include: ${JEMALLOC_INCLUDE}, lib: ${JEMALLOC_LIB}") | ||
else() | ||
message(FATAL_ERROR "Couldn't find system jemalloc") | ||
endif() | ||
else() | ||
if(BUILD_SHARED_LIBS) | ||
set(JEMALLOC_LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) | ||
else() | ||
set(JEMALLOC_LIB_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
endif() | ||
set(JEMALLOC_SRC "${PROJECT_BINARY_DIR}/jemalloc-prefix/src") | ||
set(JEMALLOC_LIB "${JEMALLOC_SRC}/jemalloc/lib/libjemalloc${JEMALLOC_LIB_SUFFIX}") | ||
set(JEMALLOC_INCLUDE "${JEMALLOC_SRC}/jemalloc/include/jemalloc") | ||
ExternalProject_Add( | ||
jemalloc | ||
PREFIX "${PROJECT_BINARY_DIR}/jemalloc-prefix" | ||
URL "https://github.com/jemalloc/jemalloc/archive/refs/tags/5.3.0.tar.gz" | ||
URL_HASH "SHA256=ef6f74fd45e95ee4ef7f9e19ebe5b075ca6b7fbe0140612b2a161abafb7ee179" | ||
CONFIGURE_COMMAND ./autogen.sh --enable-prof --disable-libdl | ||
BUILD_IN_SOURCE 1 | ||
BUILD_COMMAND make build_lib_static | ||
INSTALL_COMMAND "" | ||
UPDATE_COMMAND "" | ||
BUILD_BYPRODUCTS ${JEMALLOC_LIB} | ||
) | ||
message(STATUS "Using bundled jemalloc: include: ${JEMALLOC_INCLUDE}, lib: ${JEMALLOC_LIB}") | ||
install( | ||
FILES "${JEMALLOC_LIB}" | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${LIBS_PACKAGE_NAME}" | ||
COMPONENT "libs-deps" | ||
) | ||
endif() | ||
|
||
# We add a custom target, in this way we can always depend on `jemalloc` without distinguishing | ||
# between "bundled" and "not-bundled" case | ||
if(NOT TARGET jemalloc) | ||
add_custom_target(jemalloc) | ||
endif() | ||
|
||
include_directories(${JEMALLOC_INCLUDE}) | ||
add_compile_definitions(HAS_JEMALLOC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,9 @@ limitations under the License. | |
#include "event_drops.h" | ||
#include "falco_outputs.h" | ||
|
||
// Falco only metric | ||
#define METRICS_V2_JEMALLOC_STATS 1 << 31 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All other |
||
|
||
enum class engine_kind_t : uint8_t { KMOD, EBPF, MODERN_EBPF, REPLAY, GVISOR, NODRIVER }; | ||
|
||
// Map that holds { config filename | validation status } for each loaded config file. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing the comment about jemalloc and ASAN above, shouldn't there be a check done here that fails the configuration if both are enabled ? Otherwise we will likely have users that will get problematic builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, i'll just add a warning!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed!