Skip to content

chore: use mimalloc for codspeed benchmark allocator#204

Merged
hardfist merged 2 commits into
mainfrom
chore/bench-use-mimalloc
May 9, 2026
Merged

chore: use mimalloc for codspeed benchmark allocator#204
hardfist merged 2 commits into
mainfrom
chore/bench-use-mimalloc

Conversation

@stormslowly
Copy link
Copy Markdown
Collaborator

Summary

Port of web-infra-dev/rspack#13966 to this repo's benchmark harness.

  • Route NeverGrowInPlaceAllocator alloc/dealloc through mimalloc::MiMalloc on non-wasm targets so CodSpeed can white-box allocator activity.
  • Keep the wrapper without a realloc override to preserve never-grow-in-place benchmark behavior — realloc falls through to the default GlobalAlloc::realloc (alloc-new + copy + dealloc-old), which is what stabilizes results.
  • Keep wasm on System and align mimalloc feature flags (local_dynamic_tls on Linux, v3 everywhere) with rspack_allocator.

Verification

  • `cargo check --benches --all-features`
  • `cargo clippy --bench resolver --all-features` — no new warnings in the modified region
  • `cargo fmt --check`
  • pre-commit hooks (fmt + taplo + clippy with `-D warnings`) green

Route NeverGrowInPlaceAllocator alloc/dealloc through mimalloc::MiMalloc
on non-wasm targets so CodSpeed can white-box allocator activity. Keep
the wrapper without a realloc override to preserve never-grow-in-place
benchmark behavior. Wasm stays on System.

Ported from web-infra-dev/rspack#13966.
Copilot AI review requested due to automatic review settings May 9, 2026 04:40
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92406e97fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread benches/resolver.rs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ports rspack’s CodSpeed benchmark allocator setup into rspack-resolver by routing benchmark allocations through mimalloc (on non-wasm targets) while preserving the “never grow in place” realloc behavior to stabilize benchmark results.

Changes:

  • Add target-specific mimalloc dev-dependencies (with feature flags aligned to rspack’s benchmark harness).
  • Update the benchmark global allocator to wrap mimalloc::MiMalloc on non-wasm and System on wasm, while intentionally not overriding realloc.
  • Regenerate Cargo.lock to include mimalloc and related transitive updates.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
Cargo.toml Adds target-specific mimalloc dev-dependencies for benchmarks.
Cargo.lock Locks mimalloc + transitive dependencies and updates windows-sys entries accordingly.
benches/resolver.rs Switches benchmark global allocator to a wrapper around mimalloc (non-wasm) / System (wasm) without realloc override.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread benches/resolver.rs Outdated
Comment thread benches/resolver.rs
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 9, 2026

Merging this PR will degrade performance by 94.31%

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 9 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory resolver[resolve from symlinks multi thread] 672.5 KB 11,822.3 KB -94.31%
Simulation resolver[multi-thread] 71 ms 63.7 ms +11.4%
Simulation resolver[single-thread] 63.4 ms 56.9 ms +11.42%

Comparing chore/bench-use-mimalloc (e4d84d9) with main (3d32523)

Open in CodSpeed

@hardfist hardfist merged commit d64a1cc into main May 9, 2026
20 of 21 checks passed
@hardfist hardfist deleted the chore/bench-use-mimalloc branch May 9, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants