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

Make it possible to dlopen libfluent-bit.so #8005

Closed
wants to merge 1 commit into from

Conversation

tobim
Copy link

@tobim tobim commented Oct 5, 2023

The static copy of jemalloc that is included in the distributed fluent-bit binary packages prevents use loading the library at runtime as it is typically done in plugin systems.

A slight change to the jemalloc configuration lifts this restriction.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • [N/A] Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

The static copy of jemalloc that is included in the distributed
fluent-bit binary packages prevents use loading the library at runtime
as it is typically done in plugin systems.

A slight change to the jemalloc configuration lifts this restriction.

Signed-off-by: Tobias Mayer <[email protected]>
@tobim tobim force-pushed the unbreak-dlopen-libfluent-bit.so branch from 9fae87a to e2088ec Compare October 5, 2023 14:12
@edsiper
Copy link
Member

edsiper commented Oct 5, 2023

thanks for your contribution.

Jemalloc exists to provide better performance in memory management, by disabling that flag will affect performance per the description on this comment:

I think I would be easier if you built Fluent Bit without Jemalloc. Or have some perf comparison with and without that flag to understand potential side effects.

@tobim
Copy link
Author

tobim commented Oct 5, 2023

Thanks for your reply. I kind of agree that --disable-initial-exec-tls is not really the optimal solution, but I proposed it anyways because I was able to verify that it would work for my use-case, and it is a small change.

An arguably better approach would be to only link libjemalloc.so to the executable build targets, but not he library. One of the jemalloc developers argues in favor of that approach when the Debian maintainer asked about the very same issue in 2021.

I think I would be easier if you built Fluent Bit without Jemalloc.

Vendored dependencies cause their own set of problems and it's possible that other people run into the same problem as me. I'm still hopeful that we can find an a resolution of the issue that is acceptable for upstream inclusion.

@tobim tobim marked this pull request as draft October 5, 2023 21:10
tobim added a commit to tenzir/tenzir that referenced this pull request Oct 6, 2023
The official fluent-bit package contains a bundeld copy of jemalloc
that poses 2 problems: First, it is built in a way that makes it
impossible to load `libfluent-bit.so` with `dlopen()`. And second,
the way it initializes thread local variables creates problems with
the jemalloc present in `libarrow.so`, specifically it causes a
segfault when initializing the s3 filesystem.

I'm trying to resolve this issue upstream at
fluent/fluent-bit#8005, but until it is
fixed we have to rely on this fallback.
tobim added a commit to tenzir/tenzir that referenced this pull request Oct 6, 2023
The official fluent-bit package contains a bundeld copy of jemalloc
that poses 2 problems: First, it is built in a way that makes it
impossible to load `libfluent-bit.so` with `dlopen()`. And second,
the way it initializes thread local variables creates problems with
the jemalloc present in `libarrow.so`, specifically it causes a
segfault when initializing the s3 filesystem.

I'm trying to resolve this issue upstream at
fluent/fluent-bit#8005, but until it is
fixed we have to rely on this fallback.
@tobim
Copy link
Author

tobim commented Oct 6, 2023

Let's discuss this approach in #8011.

@tobim tobim closed this Oct 6, 2023
tobim added a commit to tenzir/tenzir that referenced this pull request Oct 6, 2023
The official fluent-bit package contains a bundeld copy of jemalloc
that poses 2 problems: First, it is built in a way that makes it
impossible to load `libfluent-bit.so` with `dlopen()`. And second,
the way it initializes thread local variables creates problems with
the jemalloc present in `libarrow.so`, specifically it causes a
segfault when initializing the s3 filesystem.

I'm trying to resolve this issue upstream at
fluent/fluent-bit#8005, but until it is
fixed we have to rely on this fallback.

Signed-off-by: Tobias Mayer <[email protected]>
@tobim tobim deleted the unbreak-dlopen-libfluent-bit.so branch October 6, 2023 08:00
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.

2 participants