mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
feat! Mimalloc as the default allocator (#434)
This change integrates mimalloc as the default memory allocator for Regorus, delivering significant performance improvements across all evaluation modes and language bindings. Technical Implementation: - Build mimalloc in vendored mode from C sources (following QSharp approach) - Implement GlobalAlloc trait for seamless Rust integration - Add optional 'mimalloc' feature flag for conditional compilation - Add comprehensive ACI benchmarks to measure evaluation performance Performance Impact: Rust Engine Evaluation: - Single-threaded: ~29% improvement (423 vs 328 Kelem/s) - Multi-threaded: Better scaling with reduced thread contention - Fresh engines: ~24% improvement (56 vs 45 Kelem/s) Rust Compiled Policy Evaluation: - Single-threaded: ~41% improvement (426 vs 303 Kelem/s) - Multi-threaded: Improved allocation efficiency under contention - Fresh compilation: ~26% improvement (53 vs 42 Kelem/s) C# FFI Bindings: - Engine evaluation: ~27% improvement (279 vs 219 Kelem/s) - Compiled policies: ~29% improvement (273 vs 211 Kelem/s) - Better threading characteristics through improved underlying allocation Key Benefits: - Reduced allocation-related contention in multi-threaded scenarios - More consistent performance across different thread counts - Improved memory allocation efficiency for both native Rust and FFI workloads - Better scaling characteristics for production deployments The mimalloc integration provides substantial performance gains while maintaining full compatibility with existing code through feature flags. Reference: QSharp allocator implementation (https://github.com/microsoft/qsharp/tree/main/source/allocator) Fixes #297 Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
6c5338228b
commit
2a0b4ae6b5
@@ -32,6 +32,7 @@ http = []
|
||||
glob = ["dep:globset"]
|
||||
graph = []
|
||||
jsonschema = ["dep:jsonschema"]
|
||||
mimalloc = ["dep:mimalloc"]
|
||||
net = []
|
||||
no_std = ["lazy_static/spin_no_std"]
|
||||
opa-runtime = []
|
||||
@@ -51,6 +52,7 @@ full-opa = [
|
||||
"hex",
|
||||
"http",
|
||||
"jsonschema",
|
||||
"mimalloc",
|
||||
"net",
|
||||
"opa-runtime",
|
||||
"regex",
|
||||
@@ -114,6 +116,7 @@ rand = { version = "0.9.0", default-features = false, features = ["thread_rng"],
|
||||
# Causes the project to link with the Spectre-mitigated CRT and libs.
|
||||
msvc_spectre_libs = { version = "0.1", features = ["error"], optional = true }
|
||||
dashmap = { version = "6.1", default-features = false, optional = true }
|
||||
mimalloc = { path = "mimalloc", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
anyhow = "1.0.45"
|
||||
@@ -170,6 +173,10 @@ name = "compiled_policy_evaluation_benchmark"
|
||||
path = "benches/evaluation/compiled_policy_evaluation_benchmark.rs"
|
||||
harness = false
|
||||
|
||||
[[bench]]
|
||||
name = "aci_benchmark"
|
||||
harness = false
|
||||
|
||||
[[example]]
|
||||
name="regorus"
|
||||
harness=false
|
||||
|
||||
Reference in New Issue
Block a user