facebookincubator / katran

A high performance layer 4 load balancer
GNU General Public License v2.0
4.75k stars 504 forks source link

Building on Other Distros + Slimmed Build + Release Prebuilt Static Libraries #182

Closed victorstewart closed 1 year ago

victorstewart commented 2 years ago

:(

root@clr-abc6f8df8c604cfcb38b40b489dc0881~/katran (main) # ./build.sh install
I don't know how to install any packages on this system linux-clear__os-37620

so i just built it in an ubuntu container, and though command issuing wise it was a simple build, i feel like i downloaded and compiled the entire Internet just to get the katranlb library (it must've been GBs upon GBs and ~30 individual compilations). took a super long time. the ubuntu image began at 77.8MB and by the time the build had completed the image was a staggering 23.8GB! (i saved the container image in case i need to get back in there).

thankfully it just produces static libraries though so easily exfiltrated the build folder from the container onto my host.

but this got me wondering... surely just getting at the static libraries is the standard use case... thus surely all of this work isn't necessary? there must be some much, much reduced build possible? or even just release the static libraries for people to download from Github?

also i assume libkatranlb.a can't be linked against a program that uses LLVM's libc++ as the program would segfault and trying to alter the build process the rebuild all of the dependencies with libc++ would be a dizzyingly impossible task? probably easier to use rewire my server library to just use GCC's libstdc++ for this one program.

thanks for Katran though!!! saved me from building it myself, though i imagine there might be a distant future where this becomes a critical piece of our infrastructure and pragmatism requires me to fork and de-dependency it into just a handful of low level libraries.

Edit:

also libkatranlb.a library is ~17M, libssl.a is ~1M, libcrypto.a is ~6M, libc++.a is ~3M. i would imagine there are significant instruction cache performance issues of this much code?

tehnerd commented 2 years ago

re size: seems like you didn't strip it:

tehnerd@tehnerd-dev:~/src/server$ ls -lah bazel-bin/external/katran/liblibkatran.a
-r-xr-xr-x 1 tehnerd tehnerd 12M Nov 14 23:51 bazel-bin/external/katran/liblibkatran.a

tehnerd@tehnerd-dev:~/src/server$ sudo strip bazel-bin/external/katran/liblibkatran.a

tehnerd@tehnerd-dev:~/src/server$ ls -lah bazel-bin/external/katran/liblibkatran.a
-r-xr-xr-x 1 tehnerd tehnerd 490K Nov 14 23:51 bazel-bin/external/katran/liblibkatran.a
tehnerd@tehnerd-dev:~/src/server$ 
victorstewart commented 2 years ago

@tehnerd thank you!

avasylev commented 2 years ago

@victorstewart yeah initial build is very slow, but subsequent builds are much faster, so it's just one time thing. Releasing built libraries is something we can do, though you're the first one I can recall raising this. In future we'd like to release katran binary as ootb L4 load balancer, but that's it's own story...

re GCC, no idea, if you make it work - please share results.

re forking, consider sending us PR instead, mini katran build sounds interesting and might be useful for others. In general you raised good issues and while we don't have immediate solution for them, we welcome all PRs.