Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .config/mise/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protoc = "32.1"

# CLI tools
biome = "1.9.5-nightly.ff02a0b"
"cargo:cargo-codspeed" = "4.1.0"
"cargo:cargo-hack" = "0.6.37"
"cargo:cargo-insta" = "1.43.1"
"cargo:cargo-llvm-cov" = "0.6.18"
Expand Down
80 changes: 80 additions & 0 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CodSpeed Benchmarks

on:
push:
branches:
- "main"
pull_request:
# `workflow_dispatch` allows CodSpeed to trigger backtest
# performance analysis in order to generate initial data.
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
setup:
runs-on: ubuntu-24.04
permissions:
id-token: write
outputs:
packages: ${{ steps.packages.outputs.packages }}
steps:
- name: Checkout source code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 2

- name: Install tools
uses: ./.github/actions/install-tools
with:
token: ${{ secrets.GITHUB_TOKEN }}
vault_address: ${{ secrets.VAULT_ADDR }}
rust: false

- name: Determine changed packages that have codspeed
id: packages
run: |
PACKAGES_QUERY='query { affectedPackages(base: "HEAD^" filter: {has: {field: "TASK_NAME", value: "build:codspeed"}}) {items {name path}}}'
PACKAGES=$(turbo query "$PACKAGES_QUERY" \
| jq --compact-output '.data.affectedPackages.items | [(.[] | select(.name != "//"))] | { name: [.[].name], include: . }')

echo "packages=$PACKAGES" | tee -a $GITHUB_OUTPUT

benchmarks:
name: Run benchmarks
needs: [setup]
runs-on: ubuntu-24.04
strategy:
matrix: ${{ fromJSON(needs.setup.outputs.packages) }}
fail-fast: false
if: needs.setup.outputs.packages != '{"name":[],"include":[]}'
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 2

- name: Clean up disk
uses: ./.github/actions/clean-up-disk

- name: Install tools
uses: ./.github/actions/install-tools
with:
token: ${{ secrets.GITHUB_TOKEN }}
vault_address: ${{ secrets.VAULT_ADDR }}

- name: Prune repository
uses: ./.github/actions/prune-repository
with:
scope: ${{ matrix.name }}

- name: Build the benchmark target
run: turbo run build:codspeed --filter=${{ matrix.name }}

- name: Run the benchmark
uses: CodSpeedHQ/action@346a2d8a8d9d38909abd0bc3d23f773110f076ad # v4.4.1
with:
mode: simulation
run: turbo run test:codspeed --filter=${{ matrix.name }}
122 changes: 119 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ circular-buffer = { version = "1.1.0", default-features = fal
clap = { version = "4.5.51", features = ["color", "error-context", "help", "std", "suggestions", "usage"] }
clap_builder = { version = "4.5.51", default-features = false, features = ["std"] }
clap_complete = { version = "4.5.60", default-features = false }
codspeed-criterion-compat = { version = "4.1.0" }
console_error_panic_hook = { version = "0.1.7", default-features = false }
convert_case = { version = "0.10.0", default-features = false }
criterion = { version = "0.8.0" }
Expand Down
6 changes: 6 additions & 0 deletions libs/@local/hashql/core/src/heap/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ impl Allocator {
Self(Bump::with_capacity(capacity))
}

/// Sets the allocation limit for the allocator.
#[inline]
pub(crate) fn set_allocation_limit(&self, capacity: Option<usize>) {
self.0.set_allocation_limit(capacity);
}

/// Allocates a value using a closure to avoid moving before allocation.
#[inline]
pub(crate) fn alloc_with<T>(&self, func: impl FnOnce() -> T) -> &mut T {
Expand Down
6 changes: 6 additions & 0 deletions libs/@local/hashql/core/src/heap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ impl Heap {
}
}

/// Sets the allocation limit for the heap.
#[inline]
pub fn set_allocation_limit(&self, capacity: Option<usize>) {
self.inner.set_allocation_limit(capacity);
}

/// Allocates a value in the arena, returning a mutable reference.
///
/// Only accepts types that do **not** require [`Drop`]. Types requiring destructors
Expand Down
9 changes: 9 additions & 0 deletions libs/@local/hashql/core/src/heap/scratch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,20 @@ pub struct Scratch {
impl Scratch {
/// Creates a new scratch allocator.
#[must_use]
#[inline]
pub fn new() -> Self {
Self {
inner: Allocator::new(),
}
}

#[must_use]
#[inline]
pub fn with_capacity(capacity: usize) -> Self {
Self {
inner: Allocator::with_capacity(capacity),
}
}
}

impl Default for Scratch {
Expand Down
11 changes: 7 additions & 4 deletions libs/@local/hashql/mir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ bstr = { workspace = true }
simple-mermaid = { workspace = true }

[dev-dependencies]
criterion = { workspace = true }
criterion-macro = { workspace = true }
hashql-compiletest = { workspace = true }
insta = { workspace = true }
codspeed-criterion-compat = { workspace = true }
hashql-compiletest = { workspace = true }
insta = { workspace = true }


[lints]
Expand All @@ -35,6 +34,10 @@ workspace = true
name = "compiletest"
harness = false

[[bench]]
name = "transform"
harness = false

[package.metadata.sync.turborepo]
ignore-dev-dependencies = [
"@rust/hashql-compiletest",
Expand Down
Loading
Loading