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

Migrate build system to Conan and CMake #136

Closed
wants to merge 51 commits into from

Conversation

hrz6976
Copy link
Contributor

@hrz6976 hrz6976 commented Jan 2, 2024

Note

THIS PR IS PROTENTIALLY BREAKING!!!!!
With a lot of file restructuring, includes renaming and reordering, the codebase is prone to break after merging this PR. I'm not able to run the entire test suite with big chunks of fixtures are missing with hard-encoded path in the code (e.g. /home/data/WatDiv/query/c3.sql.
Please double check the changes and make sure all tests pass before merging this PR.

Changes in this PR

  • Migrate the build system from hundreds of lines of hard-crafted GNU Makefile to a list of tree-structured CMakefiles.txt.
  • Integrate the Conan package manager to make developers' life easier with 3rd party libraries.
  • Use ninja-build (and optionally mold) for faster compiling and linking.

TODOs

  • Update the documentation.
  • Add a CI pipeline to automatically build and test gStore on every PR & commit to the default branch.
  • Make tests portable. (Possibly upload the fixtures to some hosting service and download them in CI?)

DISCLAIMER

This PR is a part of the course project in PKU's graph data management course.

@lsvih
Copy link
Member

lsvih commented Jan 2, 2024

Hi there,
Thank you a lot for commiting this helpful PR. Due to its HUGE size, we will need some time to review and test it. Please be patient while we go through the process.
Additionally, since the main branch is continuously being updated, it may (already) cause some conflicts with this PR. These conflicts should be resolved carefully.

Feel free to stay in touch with us!

Best regards

@hrz6976
Copy link
Contributor Author

hrz6976 commented Jan 2, 2024

How to compile gStore

Requirements

1. The build system

apt update
apt -y install build-essential cmake ninja-build mold python3-pip pkg-config
pip3 install conan
conan profile detect

The current toolchain requires gcc>=8 (for c++17), cmake >= 3.16 (for conan 2 integration and find_OpenMP), and conan >= 2.0. Only tested on Ubuntu 22.04 with gcc 11, cmake 3.22 and conan 2.0.16.

2. System packages
In theory, system packages are the last resort for projects that wants reproducible builds. Sadly we have to dynamic link system packages (e.g. gomp and libreadline ) for their license incompatibilties with BSD (especially GPL ones).

apt -y install libreadline-dev libjemalloc-dev uuid-dev libssl-dev

Compile

conan install . --output-folder=build --build=missing -s build_type=Debug # or Release, RelWithDebInfo
cd build
cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug # or Release, RelWithDebInfo
## Or if you want mold for faster and easy-to-debug linking
# cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_CXX_FLAGS="-fuse-ld=mold" -DCMAKE_BUILD_TYPE=Debug # or Release, RelWithDebInfo
ninja -v install

Well done! You will find binaries in bin, libraries in lib and test binaries in lib_tests.

@hrz6976
Copy link
Contributor Author

hrz6976 commented Jan 2, 2024

The cmake toolchain docker image has been pushed to dockerhub. It is even 60% smaller (only 87MB, 8% of the original docker image). Also the dockerfile verifies the build process from scratch gonna work.

How to use the new docker build:

This docker image has been published to dockerhub. To pull the image:

docker pull hrz6976/gstore:cmake-beta

To launch the playground mode:

docker run -it --rm hrz6976/gstore:cmake-beta sh -c "(/usr/local/bin/ghttp &); bash"

Wait for the databases to initialize, press Enter, and you are good to go:

> gquery -db small -q data/small/small_q0.sql

Run ghttp as a daemon and presist the data:

export GSTORE_PORT=9000 # or any port you want
export GSTORE_PATH=$(realpath ./gstore) # or any local directory with write permission
docker run -d -p ${GSTORE_PORT}:9000 -v ${GSTORE_PATH}:/app hrz6976/gstore:cmake-beta

To build the docker image:

ninja -C build tarball
docker build -t gstore .

@hrz6976
Copy link
Contributor Author

hrz6976 commented Jan 8, 2024

64e6dac538dfb0370a61af214b4753b Added support for loongarch64 processors! 🚀

Some of the tests have hard-coded paths to HUGE datasets (10GB compressed), so no luck for them :(
@hrz6976
Copy link
Contributor Author

hrz6976 commented Jan 13, 2024

Just resolved the merge conflicts and opened #138. Closing.

@hrz6976 hrz6976 closed this Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants