mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-02 22:03:07 +00:00
Do not export global allocator (#533)
* Do not export allocator * Make sure to use jemalloc in all downstream tests * Update readme * Remove test jemalloc boilerplate * One more * Fix clippies * One more * Clippy Co-authored-by: Daniel Lubarov <daniel@lubarov.com>
This commit is contained in:
parent
90f6d07f72
commit
7769c269bf
10
README.md
10
README.md
@ -31,7 +31,15 @@ RUSTFLAGS=-Ctarget-cpu=native cargo run --release --example bench_recursion -- -
|
||||
|
||||
## Jemalloc
|
||||
|
||||
By default, Plonky2 uses the [Jemalloc](http://jemalloc.net) memory allocator due to its superior performance. Currently, it changes the default allocator of any binary to which it is linked. You can disable this behavior by removing the corresponding lines in [`plonky2/src/lib.rs`](https://github.com/mir-protocol/plonky2/blob/main/plonky2/src/lib.rs).
|
||||
Plonky2 prefers the [Jemalloc](http://jemalloc.net) memory allocator due to its superior performance. To use it, include `jemallocator = "0.3.2"` in`Cargo.toml`and add the following lines
|
||||
to your `main.rs`:
|
||||
|
||||
```rust
|
||||
use jemallocator::Jemalloc;
|
||||
|
||||
#[global_allocator]
|
||||
static GLOBAL: Jemalloc = Jemalloc;
|
||||
```
|
||||
|
||||
Jemalloc is known to cause crashes when a binary compiled for x86 is run on an Apple silicon-based Mac under [Rosetta 2](https://support.apple.com/en-us/HT211861). If you are experiencing crashes on your Apple silicon Mac, run `rustc --print target-libdir`. The output should contain `aarch64-apple-darwin`. If the output contains `x86_64-apple-darwin`, then you are running the Rust toolchain for x86; we recommend switching to the native ARM version.
|
||||
|
||||
|
||||
@ -27,15 +27,15 @@ serde_cbor = "0.11.1"
|
||||
keccak-hash = "0.8.0"
|
||||
static_assertions = "1.1.0"
|
||||
|
||||
[target.'cfg(not(target_env = "msvc"))'.dependencies]
|
||||
jemallocator = "0.3.2"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3.5"
|
||||
tynm = "0.1.6"
|
||||
structopt = "0.3.26"
|
||||
num_cpus = "1.13.1"
|
||||
|
||||
[target.'cfg(not(target_env = "msvc"))'.dev-dependencies]
|
||||
jemallocator = "0.3.2"
|
||||
|
||||
[[bench]]
|
||||
name = "field_arithmetic"
|
||||
harness = false
|
||||
|
||||
7
plonky2/benches/allocator/mod.rs
Normal file
7
plonky2/benches/allocator/mod.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// Set up Jemalloc
|
||||
#[cfg(not(target_env = "msvc"))]
|
||||
use jemallocator::Jemalloc;
|
||||
|
||||
#[cfg(not(target_env = "msvc"))]
|
||||
#[global_allocator]
|
||||
static GLOBAL: Jemalloc = Jemalloc;
|
||||
@ -1,3 +1,5 @@
|
||||
mod allocator;
|
||||
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use plonky2::field::field_types::Field;
|
||||
use plonky2::field::goldilocks_field::GoldilocksField;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
mod allocator;
|
||||
|
||||
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
|
||||
use plonky2::field::extension_field::quadratic::QuadraticExtension;
|
||||
use plonky2::field::extension_field::quartic::QuarticExtension;
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#![allow(incomplete_features)]
|
||||
#![feature(generic_const_exprs)]
|
||||
|
||||
mod allocator;
|
||||
|
||||
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
|
||||
use plonky2::field::goldilocks_field::GoldilocksField;
|
||||
use plonky2::hash::hash_types::{BytesHash, RichField};
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#![feature(generic_const_exprs)]
|
||||
|
||||
mod allocator;
|
||||
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use plonky2::field::goldilocks_field::GoldilocksField;
|
||||
use plonky2::hash::hash_types::RichField;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
mod allocator;
|
||||
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use plonky2::field::field_types::Field;
|
||||
use plonky2::field::goldilocks_field::GoldilocksField;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
mod allocator;
|
||||
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use plonky2::field::field_types::Field;
|
||||
use plonky2::field::goldilocks_field::GoldilocksField;
|
||||
|
||||
@ -19,11 +19,3 @@ pub mod hash;
|
||||
pub mod iop;
|
||||
pub mod plonk;
|
||||
pub mod util;
|
||||
|
||||
// Set up Jemalloc
|
||||
#[cfg(not(target_env = "msvc"))]
|
||||
use jemallocator::Jemalloc;
|
||||
|
||||
#[cfg(not(target_env = "msvc"))]
|
||||
#[global_allocator]
|
||||
static GLOBAL: Jemalloc = Jemalloc;
|
||||
|
||||
@ -21,3 +21,6 @@ criterion = "0.3.5"
|
||||
[[bench]]
|
||||
name = "lookup_permuted_cols"
|
||||
harness = false
|
||||
|
||||
[target.'cfg(not(target_env = "msvc"))'.dev-dependencies]
|
||||
jemallocator = "0.3.2"
|
||||
|
||||
7
system_zero/benches/allocator/mod.rs
Normal file
7
system_zero/benches/allocator/mod.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// Set up Jemalloc
|
||||
#[cfg(not(target_env = "msvc"))]
|
||||
use jemallocator::Jemalloc;
|
||||
|
||||
#[cfg(not(target_env = "msvc"))]
|
||||
#[global_allocator]
|
||||
static GLOBAL: Jemalloc = Jemalloc;
|
||||
@ -1,3 +1,5 @@
|
||||
mod allocator;
|
||||
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use itertools::Itertools;
|
||||
use plonky2::field::field_types::Field;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user