Skip to content

Commit

Permalink
chore: precompile librocksdb for speed up tests (#788)
Browse files Browse the repository at this point in the history
## Description

Compiling the `rocksdb` crate consumes a lot of time because it compiles
`librocksdb.a` library under the hood. The PR adds additional flow in CI
to precompile this library and save it into the cache for further
re-using.
  • Loading branch information
aleksuss authored Jul 3, 2023
1 parent 418a28f commit 3c8f866
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ jobs:
uses: actions/checkout@v3
- name: Restore cache
run: |
cache-util restore cargo_git cargo_registry yarn_cache
cache-util restore aurora-engine-target@generic@${{ hashFiles('**/Cargo.lock') }}:target
cache-util restore cargo_git cargo_registry yarn_cache rocksdb:/root/rocksdb
cache-util restore aurora-engine-target@tests@${{ hashFiles('**/Cargo.lock') }}:target
- name: Preparing rocksdb library
run: scripts/ci/build_rocksdb.sh
- name: Build contracts
run: cargo make build-contracts
- name: Test contracts
Expand All @@ -40,7 +42,7 @@ jobs:
- name: Save cache
run: |
cache-util save cargo_git cargo_registry yarn_cache
cache-util msave aurora-engine-target@generic@${{ hashFiles('**/Cargo.lock') }}:target
cache-util msave aurora-engine-target@tests@${{ hashFiles('**/Cargo.lock') }}:target
test_modexp:
name: Test modexp suite (mainnet, testnet)
Expand All @@ -53,17 +55,22 @@ jobs:
uses: actions/checkout@v3
- name: Restore cache
run: |
cache-util restore cargo_git cargo_registry yarn_cache
cache-util restore aurora-engine-target@generic@${{ hashFiles('**/Cargo.lock') }}:target
cache-util restore cargo_git cargo_registry yarn_cache rocksdb:/root/rocksdb
cache-util restore aurora-engine-target@modexp@${{ hashFiles('**/Cargo.lock') }}:target
- name: Preparing rocksdb library
run: scripts/ci/build_rocksdb.sh
- name: Test mainnet bench-modexp
run: cargo make --profile mainnet bench-modexp
- name: Test testnet bench-modexp
run: cargo make --profile testnet bench-modexp
- name: Save cache
run: |
cache-util save cargo_git cargo_registry yarn_cache
cache-util msave aurora-engine-target@generic@${{ hashFiles('**/Cargo.lock') }}:target
cache-util msave aurora-engine-target@modexp@${{ hashFiles('**/Cargo.lock') }}:target
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
ROCKSDB_INCLUDE_DIR: /root/rocksdb/include
ROCKSDB_LIB_DIR: /root/rocksdb/lib
ROCKSDB_STATIC: 1
15 changes: 15 additions & 0 deletions scripts/ci/build_rocksdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

ROCKSDB_VER=v7.4.4
INSTALL_PATH=/root/rocksdb
LIB_PATH=$INSTALL_PATH/lib/librocksdb.a

if [[ ! -f $LIB_PATH ]]; then
apt -y install cmake libgflags-dev libsnappy-dev libbz2-dev liblz4-dev libzstd-dev
git clone --branch $ROCKSDB_VER https://github.com/facebook/rocksdb
cd rocksdb && mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DWITH_ZLIB=1 -DWITH_SNAPPY=1 -DWITH_LZ4=1 -DWITH_ZSTD=1 -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH ..
make -j32 install
cache-util save rocksdb:$INSTALL_PATH
cd $HOME
fi

0 comments on commit 3c8f866

Please sign in to comment.