Why fdbserver binary size so big by compiling from source code?

I compiled fdb according to GitHub - FoundationDB/fdb-build-support: FoundationDB build and development resources from source code(tag: 7.1.26).

Then I got follow binarys (with size):

487M    build_output/bin/fdbbackup
20K     build_output/bin/fdb_c90_test
25M     build_output/bin/fdb_c_api_tester
1.6M    build_output/bin/fdb_c_client_memory_test
575M    build_output/bin/fdbcli
462M    build_output/bin/fdbconvert
144K    build_output/bin/fdb_c_performance_test
84K     build_output/bin/fdb_c_ryw_benchmark
4.3M    build_output/bin/fdb_c_setup_tests
52K     build_output/bin/fdb_c_txn_size_test
66M     build_output/bin/fdb_c_unit_tests
4.3M    build_output/bin/fdb_c_unit_tests_version_510
463M    build_output/bin/fdbdecode
0       build_output/bin/fdbdr
4.5M    build_output/bin/fdbmonitor
0       build_output/bin/fdbrestore
4.2G    build_output/bin/fdbserver

Especially the fdbserver binary, its size reaches 4.2GB. However, I found fdbserver only 80MB in image foundationdb/foundationdb:7.1.26

Did you turn on the release flag?

These steps worked for me on foundationdb/build:centos7-latest

  • git clone --depth 1 --branch (branch or tag comes here) https://github.com/apple/foundationdb.git
  • mkdir build
  • cd build
  • source /opt/rh/devtoolset-11/enable && source /opt/rh/rh-python38/enable && cmake -DFDB_RELEASE=ON -G Ninja ../foundationdb
  • ninja -j4
  • cpack -G DEB (or RPM)

Those binaries are huge because they include the debugging information if you’re not doing a release.

try this:

cmake -S . -B build_output \
   -DCMAKE_BUILD_TYPE=RelWithDebug \
  -G Ninja

ninja -v -C build_output fdbserver strip_targets -j32

# du -sh build_output/packages/bin/fdbserver
139M	build_output/packages/bin/fdbserver

Nice. It works for me.