pulse_map 0.6.5

A CPU cache-line hash table with zero-cost eviction. Every bucket fits in exactly one 64-byte cache line with embedded LFU+LRU eviction metadata.
Documentation
name: Rust CI

on:
  push:
    branches: [main, develop]
    tags: ["v*"]
  pull_request:
    branches: [main]

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  # ═══════════════════════════════════════════════════════════
  # Format Check
  # ═══════════════════════════════════════════════════════════
  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - run: cargo fmt -p pulse_map -- --check

  # ═══════════════════════════════════════════════════════════
  # Clippy Lint
  # ═══════════════════════════════════════════════════════════
  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
      - run: cargo clippy -p pulse_map -- -D warnings
      - run: cargo clippy -p pulse_map --no-default-features -- -D warnings
      - run: cargo clippy -p pulse_map --features simd -- -D warnings

  # ═══════════════════════════════════════════════════════════
  # Build + Test (multi-platform)
  # ═══════════════════════════════════════════════════════════
  test:
    name: Test (${{ matrix.os }} / ${{ matrix.rust }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        rust: [stable, nightly]
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}
      - uses: Swatinem/rust-cache@v2

      # Build
      - name: Build (default features)
        run: cargo build -p pulse_map

      - name: Build (no_std)
        run: cargo build -p pulse_map --no-default-features

      - name: Build (simd)
        if: matrix.os != 'macos-latest'
        run: cargo build -p pulse_map --features simd

      # Test
      - name: Test (default features)
        run: cargo test -p pulse_map

      - name: Test (no_std)
        run: cargo test -p pulse_map --no-default-features

      - name: Test (simd)
        if: matrix.os != 'macos-latest'
        run: cargo test -p pulse_map --features simd

  # ═══════════════════════════════════════════════════════════
  # Miri (undefined behavior in unsafe code)
  # ═══════════════════════════════════════════════════════════
  miri:
    name: Miri
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: miri
      - name: Run Miri (core engine, no_std path)
        run: cargo miri test -p pulse_map --no-default-features
      # --lib skips doc-tests: they re-run the same code paths at roughly the same cost.
      - name: Run Miri (std, concurrent + sharded)
        run: cargo miri test -p pulse_map --lib

  # ═══════════════════════════════════════════════════════════
  # loom (concurrency interleavings in lock-free code)
  # ═══════════════════════════════════════════════════════════
  loom:
    name: Loom
    runs-on: ubuntu-latest
    env:
      RUSTFLAGS: --cfg loom
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      # Only the loom_* integration tests. `--cfg loom` swaps the engine's atomics
      # for loom's instrumented ones, which panic outside a `loom::model`, so the
      # 58 unit tests deliberately stay out of this job.
      - name: Run loom models
        run: cargo test -p pulse_map --test loom_meta --test loom_access_buffer

  # ═══════════════════════════════════════════════════════════
  # Embedded no_std Check
  # ═══════════════════════════════════════════════════════════
  # One job per atomic capability class — that is the only axis that can break a
  # bare-metal build here. MetaWord is an AtomicU64, and portable-atomic can only
  # hand one out where the target gives it some form of atomic CAS to build on.
  no_std:
    name: no_std (${{ matrix.target }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          # 32-bit CAS present: portable-atomic's spinlock fallback provides AtomicU64.
          - { target: thumbv7m-none-eabi, extra: "" }            # Cortex-M3
          - { target: thumbv7em-none-eabihf, extra: "" }         # Cortex-M4F / M7F
          - { target: thumbv8m.main-none-eabi, extra: "" }       # Cortex-M33
          - { target: riscv32imac-unknown-none-elf, extra: "" }  # RISC-V with the A extension
          - { target: wasm32-unknown-unknown, extra: "" }
          # Native 64-bit atomics, no fallback involved.
          - { target: aarch64-unknown-none, extra: "" }          # 64-bit bare metal
          # No atomic CAS at any width: AtomicU64 has to go through a critical section.
          - { target: thumbv6m-none-eabi, extra: "--features critical-section" }           # Cortex-M0 / M0+ (RP2040)
          - { target: riscv32imc-unknown-none-elf, extra: "--features critical-section" }  # ESP32-C3
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - name: Check no_std compilation
        run: cargo check -p pulse_map --target ${{ matrix.target }} --no-default-features ${{ matrix.extra }}

  # ═══════════════════════════════════════════════════════════
  # QEMU (runs the no_std code, instead of only compiling it)
  # ═══════════════════════════════════════════════════════════
  # The no_std job above proves the crate compiles for these targets; cargo check
  # does not even link. This one boots a real ELF on an emulated Cortex-M and
  # exercises MetaWord's AtomicU64 CAS at runtime. Cortex-M0 is the case that
  # matters: it has no CAS instruction at all, so the `critical-section` feature
  # is the only thing making the map work there.
  qemu:
    name: QEMU (${{ matrix.machine }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - { target: thumbv7m-none-eabi, machine: cortex-m3, extra: "" }
          - { target: thumbv6m-none-eabi, machine: cortex-m0, extra: "--features m0" }
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - uses: Swatinem/rust-cache@v2
        with:
          workspaces: qemu-test
      # qemu-system-arm only; its qemu-efi-aarch64 recommend is 322 MB of
      # aarch64 UEFI firmware that nothing here boots.
      - name: Install QEMU
        run: sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-arm
      # Separate workspace with its own runner in .cargo/config.toml, so this
      # cannot be driven from the repo root.
      - name: Run on emulated hardware
        working-directory: qemu-test
        run: cargo run --release --target ${{ matrix.target }} ${{ matrix.extra }}
      # RAM and flash cost against `lru` — the only other cache in the README's
      # comparison that builds without std. Printed, not gated: it is evidence for
      # the docs, and a size gate would need a stored baseline to diff against.
      - name: Footprint vs lru
        working-directory: qemu-test
        run: |
          for b in footprint_none footprint_pulse footprint_lru; do
            cargo run -q --release --target ${{ matrix.target }} ${{ matrix.extra }} --bin "$b"
          done
          ./size.sh ${{ matrix.target }}

  # ═══════════════════════════════════════════════════════════
  # MSRV (Minimum Supported Rust Version)
  # ═══════════════════════════════════════════════════════════
  msrv:
    name: MSRV (1.70.0)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: "1.70.0"
      - run: cargo check -p pulse_map
      - run: cargo check -p pulse_map --no-default-features
      - run: cargo build -p pulse_map

  # ═══════════════════════════════════════════════════════════
  # Documentation
  # ═══════════════════════════════════════════════════════════
  docs:
    name: Docs
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo doc -p pulse_map --no-deps
        env:
          RUSTDOCFLAGS: -D warnings

  # ═══════════════════════════════════════════════════════════
  # Publish to crates.io (on tag push only)
  # ═══════════════════════════════════════════════════════════
  publish:
    name: Publish to crates.io
    needs: [fmt, clippy, test, msrv, docs]
    runs-on: ubuntu-latest
    if: false # Disabled: startsWith(github.ref, 'refs/tags/v')
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Publish
        run: cargo publish -p pulse_map
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}