Skip to content

Conversation

@tarcieri
Copy link
Member

@tarcieri tarcieri commented Dec 5, 2023

Eliminates several allocations by performing most operations of a Montgomery reduction in-place.

Only conditionally adding the modulus presently incurs an allocation.

Benchmarks

Montgomery arithmetic/BoxedResidue creation
                        time:   [135.30 ns 135.50 ns 135.76 ns]
                        change: [-36.403% -36.104% -35.794%] (p = 0.00 < 0.05)
                        Performance has improved.

Montgomery arithmetic/BoxedResidue retrieve
                        time:   [203.59 ns 204.01 ns 204.45 ns]
                        change: [-17.533% -16.947% -16.403%] (p = 0.00 < 0.05)
                        Performance has improved.

Montgomery arithmetic/multiplication, BoxedUint*BoxedUint
                        time:   [223.19 ns 223.76 ns 224.40 ns]
                        change: [-19.576% -19.107% -18.645%] (p = 0.00 < 0.05)
                        Performance has improved.

Montgomery arithmetic/modpow, BoxedUint^BoxedUint
                        time:   [58.927 µs 59.009 µs 59.103 µs]
                        change: [-18.486% -18.227% -17.952%] (p = 0.00 < 0.05)
                        Performance has improved.

Eliminates several allocations by performing most operations of a
Montgomery reduction in-place.

Only conditionally adding the modulus presently incurs an allocation.

Montgomery arithmetic/BoxedResidue creation
                        time:   [135.30 ns 135.50 ns 135.76 ns]
                        change: [-36.403% -36.104% -35.794%] (p = 0.00 < 0.05)
                        Performance has improved.

Montgomery arithmetic/BoxedResidue retrieve
                        time:   [203.59 ns 204.01 ns 204.45 ns]
                        change: [-17.533% -16.947% -16.403%] (p = 0.00 < 0.05)
                        Performance has improved.

Montgomery arithmetic/multiplication, BoxedUint*BoxedUint
                        time:   [223.19 ns 223.76 ns 224.40 ns]
                        change: [-19.576% -19.107% -18.645%] (p = 0.00 < 0.05)
                        Performance has improved.

Montgomery arithmetic/modpow, BoxedUint^BoxedUint
                        time:   [58.927 µs 59.009 µs 59.103 µs]
                        change: [-18.486% -18.227% -17.952%] (p = 0.00 < 0.05)
                        Performance has improved.
@tarcieri tarcieri merged commit 2a08643 into master Dec 5, 2023
@tarcieri tarcieri deleted the boxed-residue/in-place-montgomery-reductions branch December 5, 2023 02:04
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.

2 participants