Skip to main content
Version: DEV

Build from Source

This document provides instructions for building Infinity from source, as well as building and running unit and functional tests.

NOTE

Infinity can be natively compiled on Linux only. For non-Linux operating systems, build it using Docker.

Prerequisites

1. Replace the native Out-Of-Memory killer

Building the entire project, particularly during the link stage, requires considerable RAM, which can cause the host machine to become unresponsive due to the sluggishness of the kernel's Out-Of-Memory (OOM) killer. To mitigate this, we recommend installing earlyoom to improve the host's responsiveness.

Configure cmake to limit the number of concurrent link processes. For example:

-DCMAKE_JOB_POOLS:STRING='link=4'

NOTE

Recommended link pool size settings are as follows:

  • 1: 6 GB of RAM
  • 2: 16 GB of RAM
  • 3: 32 GB of RAM

3. Set the cmake build type

The cmake build type (CMAKE_BUILD_TYPE) can be one of the following:

  • Debug: Suitable for daily development.
    No inline; with symbol info; with address sanitizer.
    Typically ~10x slower than RelWithDebInfo or Release.
  • RelWithDebInfo: Suitable for performance analysis.
    Optimizes with -O2; with symbol information.
  • Release: Suitable for project releases. Optimizes with -O3; without symbol information.
    The built executables are significantly smaller than those of RelWithDebInfo.
NOTE

The following procedures set CMAKE_BUILD_TYPE to Debug. Change it as you see necessary.

Build the source code

This section provides instructions for building Infinity from source on Linux using Docker.

  1. Download the source code:
git clone https://github.com/infiniflow/infinity.git
  1. Build the source code using Docker:
cd infinity && mkdir cmake-build-debug
TZ=$(readlink -f /etc/localtime | awk -F '/zoneinfo/' '{print $2}')
docker run -d --name infinity_build -e TZ=$TZ -v $PWD:/infinity -v /boot:/boot infiniflow/infinity_builder:centos7_clang18
docker exec infinity_build bash -c "cd /infinity/cmake-build-debug && cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON .. && cmake --build . -t infinity"
  1. Start up the Infinity server:
sudo mkdir -p /var/infinity && sudo chown -R $USER /var/infinity
ulimit -n 500000
./cmake-build-debug/src/infinity

Build and run unit tests

docker exec infinity_build bash -c "cd /infinity/cmake-build-debug && cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON .. && cmake --build . -t  test_main"
./cmake-build-debug/src/test_main

Build and run functional tests

  1. Build and start up the Infinity server:

    docker exec infinity_build bash -c "cd /infinity/cmake-build-debug && cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON .. && cmake --build . -t  infinity"
    ./cmake-build-debug/src/infinity
  2. Install Python sdk of infinity:

    pip install infinity-sdk==0.5.0.dev4
  3. Run the functional tests:

    python3 tools/run_pytest_parallel.py