Skip to main content

PolynomialArena

Struct PolynomialArena 

Source
pub struct PolynomialArena { /* private fields */ }
Expand description

Specialized handle for Polynomial and FFT data.

Optimized for cache-line alignment and massive vectors.

Implementations§

Source§

impl PolynomialArena

Source

pub fn new(inner: Arc<BumpAlloc>) -> Self

Create a new PolynomialArena wrapping a BumpAlloc.

Source

pub fn alloc_fft_friendly(&self, size: usize) -> *mut u8

Allocate polynomial data with 64-byte alignment for optimal FFT/NTT performance.

This alignment is critical for SIMD-accelerated operations:

  • AVX-512: Requires 64-byte alignment
  • AVX/AVX2: Benefits from 32-byte alignment (64 is a superset)
  • Cache efficiency: Modern cache lines are 64 bytes
Source

pub fn alloc_huge(&self, size: usize) -> *mut u8

Allocate huge vectors with page alignment (4096 bytes).

Use this for vectors exceeding a few megabytes. Benefits:

  • TLB efficiency: Reduces translation lookaside buffer misses
  • Huge pages: May enable transparent huge page usage on Linux
  • DMA compatibility: Required for some hardware accelerators
Source

pub fn alloc(&self, size: usize, align: usize) -> *mut u8

Allocate with custom alignment.

Use this when you have specific alignment requirements. Alignment must be a power of two.

Source

pub unsafe fn alloc_slice<T>(&self, count: usize) -> *mut T

Allocate a typed slice of elements with appropriate alignment.

This is a convenience method for allocating arrays of field elements or other ZK primitive types.

§Safety

The returned pointer must be properly aligned for type T. The caller is responsible for initializing the memory.

Source

pub unsafe fn reset(&self)

Reset the polynomial arena.

§Safety

All previously allocated polynomial memory becomes invalid.

Source

pub fn remaining(&self) -> usize

Get the remaining capacity in bytes.

Source

pub fn used(&self) -> usize

Get the number of bytes currently allocated.

Source

pub fn capacity(&self) -> usize

Get the total capacity in bytes.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.