Beta weight vega greeks against volatility index instruments (#4097) #1121
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: performance | |
| permissions: # Principle of least privilege | |
| contents: read | |
| actions: read | |
| on: | |
| push: | |
| branches: [nightly] | |
| jobs: | |
| performance-benchmarks: | |
| runs-on: [self-hosted, Linux, X64, self-hosted-linux-x86] | |
| env: | |
| BUILD_MODE: release | |
| RUST_BACKTRACE: 1 | |
| # Outside the workspace so it survives actions/checkout's git clean -ffdx, | |
| # giving us persistent on-disk Rust artifact reuse between runs. | |
| CARGO_TARGET_DIR: /home/runner/.cache/cargo-target/performance-py3.12 | |
| SCCACHE_CACHE_SIZE: 1G | |
| # yamllint disable rule:line-length | |
| services: | |
| redis: | |
| image: public.ecr.aws/docker/library/redis:7.4.5-alpine3.21@sha256:bb186d083732f669da90be8b0f975a37812b15e913465bb14d845db72a4e3e08 | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| postgres: | |
| image: public.ecr.aws/docker/library/postgres:16.4-alpine@sha256:5660c2cbfea50c7a9127d17dc4e48543eedd3d7a41a595a2dfa572471e37e64c | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: pass | |
| POSTGRES_DB: nautilus | |
| ports: | |
| - 5432:5432 | |
| options: --health-cmd "pg_isready -U postgres -d nautilus" --health-interval 10s --health-timeout 5s --health-retries | |
| 5 | |
| # yamllint enable rule:line-length | |
| steps: | |
| # https://github.com/step-security/harden-runner | |
| - uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1 | |
| with: | |
| egress-policy: ${{ vars.STEP_SECURITY_EGRESS_POLICY || 'block' }} | |
| # Required for CodSpeed results upload | |
| allowed-endpoints: >- | |
| ${{ vars.COMMON_ALLOWED_ENDPOINTS }} | |
| ${{ vars.CI_ALLOWED_ENDPOINTS }} | |
| api.codspeed.io:443 | |
| *.s3.eu-west-1.amazonaws.com:443 | |
| - name: Checkout repository | |
| # https://github.com/actions/checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| fetch-depth: 1 | |
| # Temporary: fail fast on rare runner worktree corruption while we isolate the root cause | |
| - name: Verify immutable CI inputs (post-checkout) | |
| run: bash scripts/ci/verify-ci-inputs.sh post-checkout | |
| - name: Aggressive disk cleanup (pre-setup) | |
| if: runner.os == 'Linux' && !startsWith(runner.name, 'nautilus-ci-runner-') | |
| run: | | |
| set -euxo pipefail | |
| sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/share/boost || true | |
| sudo rm -rf /usr/local/lib/android /usr/lib/jvm /usr/lib/mono || true | |
| sudo rm -rf /opt/hostedtoolcache/go /opt/hostedtoolcache/node || true | |
| if [ -n "${AGENT_TOOLSDIRECTORY:-}" ] && [ -d "$AGENT_TOOLSDIRECTORY" ]; then | |
| # Remove big toolcache components but keep Python intact | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY/CodeQL" \ | |
| "$AGENT_TOOLSDIRECTORY/Go" \ | |
| "$AGENT_TOOLSDIRECTORY/Node" \ | |
| "$AGENT_TOOLSDIRECTORY/node" \ | |
| "$AGENT_TOOLSDIRECTORY/Ruby" \ | |
| "$AGENT_TOOLSDIRECTORY/PyPy" \ | |
| "$AGENT_TOOLSDIRECTORY/R" \ | |
| "$AGENT_TOOLSDIRECTORY"/Java* || true | |
| fi | |
| sudo apt-get clean | |
| sudo apt-get autoremove -y | |
| sudo rm -rf /var/lib/apt/lists/* /usr/share/man /usr/share/doc || true | |
| df -h | |
| - name: Common setup | |
| uses: ./.github/actions/common-setup | |
| with: | |
| python-version: "3.12" | |
| # free-disk-space auto-skips on the nautilus-ci-runner-* pool. | |
| free-disk-space: "true" | |
| # Persistent CARGO_TARGET_DIR replaces Swatinem/rust-cache here. | |
| rust-cache-enabled: "false" | |
| - name: Prune unused Docker images | |
| if: runner.os == 'Linux' && !startsWith(runner.name, 'nautilus-ci-runner-') | |
| run: | | |
| docker image prune -a -f || true | |
| - name: Install Nautilus CLI | |
| env: | |
| NAUTILUS_CLI_FORCE_SOURCE: ${{ github.ref == 'refs/heads/nightly' && '1' || '0' }} | |
| run: bash scripts/ci/install-nautilus-cli.sh | |
| - name: Init postgres schema | |
| run: nautilus database init --schema ${{ github.workspace }}/schema/sql | |
| env: | |
| POSTGRES_HOST: localhost | |
| POSTGRES_PORT: 5432 | |
| POSTGRES_USERNAME: postgres | |
| POSTGRES_PASSWORD: pass | |
| POSTGRES_DATABASE: nautilus | |
| - name: Set compile jobs from cache state | |
| run: bash scripts/ci/set-cargo-build-jobs.sh | |
| - name: Run Rust tests | |
| run: make cargo-test NEXTEST_PROFILE=ci | |
| # TODO: Add nautilus-persistence once required test data available | |
| - name: Run Rust benchmarks crate-by-crate | |
| env: | |
| # Shrink bench artifacts to reduce disk usage | |
| RUSTFLAGS: -Cdebuginfo=0 | |
| CARGO_PROFILE_BENCH_DEBUG: 0 | |
| CARGO_PROFILE_BENCH_INCREMENTAL: false | |
| run: make cargo-ci-benches | |
| # Temporary: fail fast on rare runner worktree corruption while we isolate the root cause | |
| - name: Verify immutable CI inputs (pre-wheel build) | |
| run: bash scripts/ci/verify-ci-inputs.sh pre-wheel-build | |
| - name: Build and install wheel | |
| uses: ./.github/actions/common-wheel-build | |
| with: | |
| python-version: "3.12" | |
| github_ref: ${{ github.ref }} | |
| # Skip on the nautilus-ci-runner-* pool: those machines keep CARGO_TARGET_DIR | |
| # and ~/.cargo persistent across runs as the primary cache strategy. | |
| - name: Cleanup build artifacts and caches | |
| if: runner.os == 'Linux' && !startsWith(runner.name, 'nautilus-ci-runner-') | |
| run: | | |
| set -euxo pipefail | |
| rm -rf "$CARGO_TARGET_DIR" target || true | |
| rm -rf ~/.cargo/registry ~/.cargo/git || true | |
| uv cache prune || true | |
| rm -rf dist build || true | |
| # Run codspeed once only | |
| - name: Run benchmarks | |
| # https://github.com/CodSpeedHQ/action | |
| uses: CodSpeedHQ/action@c381be0bfd20e844fb45594f6aa182ffcd94545c # v4.15.0 | |
| with: | |
| token: ${{ secrets.CODSPEED_TOKEN }} | |
| mode: instrumentation | |
| run: uv run --no-sync pytest tests/performance_tests --benchmark-disable-gc --codspeed |