plonky2 icon indicating copy to clipboard operation
plonky2 copied to clipboard

fix: remove trivial allocations and `try_into`

Open Daniel-Aaron-Bloom opened this issue 1 year ago • 2 comments

Use the following array tools to avoid allocations and try_into calls:

  • core::array::from_fn/core::array::try_from_fn
  • [T]::first_chunk
  • [T]::array_chunks
  • [T; N]::map
  • iter_fixed::IntoIteratorFixed

Some of the try_into calls are more of a nit just because they look like allocations but are really just slice conversions, but it was easier to just get rid of all of them.

Daniel-Aaron-Bloom avatar Apr 17 '24 22:04 Daniel-Aaron-Bloom

Fair.

I would note though that specialization is probably the least likely feature to be stabilized in the near future, so depending on your plans to remove that from plonky2_field, the introduction of these features may or may not lengthen the timeline to stability (assuming that's your goal).

Other than micro-benchmarks, but there's no real perf impact of this change. I can trim it down to just the stable if there's any interest in that.

Daniel-Aaron-Bloom avatar Apr 18 '24 00:04 Daniel-Aaron-Bloom

I would note though that specialization is probably the least likely feature to be stabilized in the near future, so depending on your plans to remove that from plonky2_field, the introduction of these features may or may not lengthen the timeline to stability (assuming that's your goal).

I'd rather avoid adding more unstable features no matter what tbh.

Other than micro-benchmarks, but there's no real perf impact of this change. I can trim it down to just the stable if there's any interest in that.

I'm open to that.

muursh avatar Apr 18 '24 11:04 muursh

Closing for inactivity.

Nashtare avatar Aug 06 '24 12:08 Nashtare