From 42a7f63f8296026984dec5f0cba95ec355eab453 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Mon, 13 May 2024 18:08:32 +0300 Subject: [PATCH 1/4] add some additional perf features for reth dep --- bin/mev/Cargo.toml | 2 +- nix/mev-rs.nix | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/mev/Cargo.toml b/bin/mev/Cargo.toml index 6fd39cff..2a18acb5 100644 --- a/bin/mev/Cargo.toml +++ b/bin/mev/Cargo.toml @@ -35,4 +35,4 @@ clap = { workspace = true, features = ["derive", "env"] } eyre = { workspace = true } ethereum-consensus = { workspace = true } -reth = { workspace = true, optional = true } +reth = { workspace = true, optional = true, features = ["jemalloc"] } diff --git a/nix/mev-rs.nix b/nix/mev-rs.nix index f989de80..67cac2a5 100644 --- a/nix/mev-rs.nix +++ b/nix/mev-rs.nix @@ -6,6 +6,7 @@ let pname = "mev-rs"; src = crane.cleanCargoSource (crane.path ../.); CARGO_PROFILE = "maxperf"; + RUSTFLAGS = "-C target-cpu=native"; cargoExtraArgs = "--locked ${feature-set}"; buildInputs = lib.optionals pkgs.stdenv.isLinux [ openssl From 3888cefdb88acfe4cde6f83ea2dc3ac5608616fe Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Mon, 13 May 2024 18:12:14 +0300 Subject: [PATCH 2/4] add docker push workflow --- .github/workflows/docker.yml | 59 ++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..0c737cae --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,59 @@ +name: docker + +on: + push: + branches: + - main + tags: + - v* + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + IMAGE_NAME: ${{ github.repository_owner}}/mev-rs + +jobs: + extract-version: + runs-on: ubuntu-22.04 + steps: + - name: Extract version (if main) + if: github.event.ref == 'refs/heads/main' + run: | + echo "VERSION=latest" >> $GITHUB_ENV + - name: Extract version (if tagged release) + if: startsWith(github.event.ref, 'refs/tags') + run: | + echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV + outputs: + VERSION: ${{ env.VERSION }} + build-docker: + name: build-docker-${{ matrix.binary }} + runs-on: ubuntu-22.04 + strategy: + matrix: + binary: [x86_64] + include: + - profile: maxperf + + needs: [extract-version] + env: + VERSION: ${{ needs.extract-version.outputs.VERSION }} + steps: + - uses: actions/checkout@v4 + - name: Dockerhub login + run: | + echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push + uses: docker/build-push-action@v5 + with: + file: ./Dockerfile + context: . + platforms: linux/x86_64 + push: true + tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }} From 2620e7924bfed07f9329da26c43ede829ef2fd45 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Mon, 13 May 2024 18:32:10 +0300 Subject: [PATCH 3/4] use `maxperf` profile for Docker build by default --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 019a2470..5347f4e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ RUN cargo chef prepare --recipe-path recipe.json FROM chef AS builder COPY --from=planner /app/recipe.json recipe.json -ARG BUILD_PROFILE=release +ARG BUILD_PROFILE=maxperf ENV BUILD_PROFILE ${BUILD_PROFILE} ARG FEATURES="" ENV FEATURES ${FEATURES} From 8d8fa69f7f1a0cdcbfd40872df5494d54b06da24 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Mon, 13 May 2024 18:32:46 +0300 Subject: [PATCH 4/4] use `maxperf` profile for release CI builds --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b353896b..854ee632 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,7 +54,7 @@ jobs: - name: Build mev-rs run: | - cargo install --path bin/mev --locked + cargo install --profile maxperf --path bin/mev --locked mkdir artifacts mv ~/.cargo/bin/mev ./artifacts cd artifacts