[improve][build] Support building docker images that use Wolfi base image which is glibc based - #24692
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #24692 +/- ##
============================================
+ Coverage 74.21% 74.23% +0.01%
+ Complexity 33463 33108 -355
============================================
Files 1895 1895
Lines 147954 147954
Branches 17130 17130
============================================
+ Hits 109805 109831 +26
+ Misses 29387 29372 -15
+ Partials 8762 8751 -11
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
nodece
left a comment
There was a problem hiding this comment.
Overall, it looks good to me. Could you add a job to build the Wolfi base image in the GHA? It would be great to verify that as well.
@nodece I pushed changes to build the Wolfi images when there are file changes directly related to Dockerfile.wolfi files so that our CI doesn't become slower. There's also the choice to manually trigger a build that uses the Wolfi base images. PTAL
|
…guard/wolfi-base fails in GitHub Actions
…mage which is glibc based (apache#24692)
…mage which is glibc based (apache#24692)

Motivation
Mailing list thread: https://lists.apache.org/thread/281kwr6txg6zgtqx5lry0fcox66gky6n
One of the drawbacks of the Alpine based image is that it's based on the "musl" libc library which causes incompatibilities for binaries that are compiled for glibc library. In Pulsar, we have already resolved this for binaries distributed with Pulsar and Pulsar IO connectors.
However, there's another disadvantage. The memory allocation library (malloc) in Alpine doesn't contain any tuneables and in Alpine, there's no documentation how to tune malloc operations.
It's possible to replace the default malloc library with other allocation libraries, but this could cause other instability.
For benchmarking purposes, it would be useful to be able to build a glibc based Docker image for Pulsar and specify glibc memory allocation tuneables.
Various glibc tuneables can be viewed with this command:
The reference: https://sourceware.org/glibc/manual/latest/html_node/Memory-Allocation-Tunables.html
For example, to enable Transparent Huge Pages (THP) for malloc allocations:
Great resources about Transparent Huge Pages in Linux:
Alpine musl malloc criticism:
For performance testing, it might be useful to also set
glibc.malloc.mmap_thresholdto the bytes value of 2MB:For k8s or Docker configurations
GLIBC_TUNABLESwould be passed with the valueglibc.malloc.hugetlb=1:glibc.malloc.mmap_threshold=2097152.The reason why this matters is that most of BookKeeper's and Pulsar's memory is allocated by Netty. Under the covers the allocations are made using
os::mallocwhich maps to the glibcmalloc. To get the performance benefits of Transparent Huge Pages, it's necessary that the allocations to the operating system are made using mmap with madvise forMADV_HUGEPAGE. The Java VM will handle this for the Java heap memory with-XX:+TransparentHugePages, but that's not sufficient, since it doesn't cover the allocations made by Netty and RocksDB. When the malloc library has support for THP, there are better ways to control the behavior. When using glibc, it will mark the large allocations withMADV_HUGEPAGEwhenglibc.malloc.hugetlb=1is used and closes that gap for Pulsar.THP is also supported in many other allocators and for example Microsoft's mimalloc (https://github.com/microsoft/mimalloc) could be another option. However, I faced some stability issues with it on Alpine. It's possibly an issue when
LD_PRELOADcontains bothgcompatandmimalloclibraries. In the Alpine images,gcompatis required for supporting Netty native libraries which have been built for glibc. This compatibility issue is also solved by using the Wolfi image.Additional Information
See #24688 regarding profiling.
Modifications
Dockerfile.wolfiforpulsarandpulsar-allimages.apkfor package management like Alpine and package names are similar-Pdocker-wolfiis passed to the command lineDocumentation
docdoc-requireddoc-not-neededdoc-complete