Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(prover): reduce synchronization allocs for FFT #668

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

estensen
Copy link
Contributor

Replace channel-based synchronization with sync.WaitGroup.

I think the primary reason is eliminating channel allocs in the recursive calls.

Benchmark results on M4 Pro show ~17% reduction in memory allocations (from ~8.2KB to ~6.7KB per operation) while ns/op remains similar.

Before

pkg: github.com/consensys/linea-monorepo/prover/maths/fft
BenchmarkFFT/fft_2**8-12                  127771              9392 ns/op               0 B/op          0 allocs/op
BenchmarkFFT/fft_2**9-12                   41942             28490 ns/op            1128 B/op         19 allocs/op
BenchmarkFFT/fft_2**10-12                  29746             40334 ns/op            2616 B/op         45 allocs/op
BenchmarkFFT/fft_2**11-12                  17817             67836 ns/op            4824 B/op         85 allocs/op
BenchmarkFFT/fft_2**12-12                  10000            111118 ns/op            8217 B/op        149 allocs/op
BenchmarkFFT/fft_2**13-12                   6920            174276 ns/op            8216 B/op        149 allocs/op
BenchmarkFFT/fft_2**14-12                   4262            279231 ns/op            8216 B/op        149 allocs/op
BenchmarkFFT/fft_2**15-12                   2568            492729 ns/op            8216 B/op        149 allocs/op
BenchmarkFFT/fft_2**16-12                   1305            890350 ns/op            8216 B/op        149 allocs/op
BenchmarkFFT/fft_2**17-12                    686           1762311 ns/op            8216 B/op        149 allocs/op
BenchmarkFFT/fft_2**18-12                    333           3620180 ns/op            8218 B/op        149 allocs/op
BenchmarkFFT/fft_2**19-12                    157           7404848 ns/op            8216 B/op        149 allocs/op

After

BenchmarkFFT/fft_2**8-12                  126274              9503 ns/op               0 B/op          0 allocs/op
BenchmarkFFT/fft_2**9-12                   41919             28420 ns/op            1032 B/op         19 allocs/op
BenchmarkFFT/fft_2**10-12                  29798             40198 ns/op            2328 B/op         45 allocs/op
BenchmarkFFT/fft_2**11-12                  17816             67560 ns/op            4152 B/op         85 allocs/op
BenchmarkFFT/fft_2**12-12                  10000            111115 ns/op            6777 B/op        149 allocs/op
BenchmarkFFT/fft_2**13-12                   6847            182320 ns/op            6776 B/op        149 allocs/op
BenchmarkFFT/fft_2**14-12                   4046            277555 ns/op            6776 B/op        149 allocs/op
BenchmarkFFT/fft_2**15-12                   2565            463729 ns/op            6776 B/op        149 allocs/op
BenchmarkFFT/fft_2**16-12                   1388            876708 ns/op            6777 B/op        149 allocs/op
BenchmarkFFT/fft_2**17-12                    682           1774575 ns/op            6778 B/op        149 allocs/op
BenchmarkFFT/fft_2**18-12                    336           3605445 ns/op            6776 B/op        149 allocs/op
BenchmarkFFT/fft_2**19-12                    160           7456658 ns/op            6776 B/op        149 allocs/op

Copy link

cla-assistant bot commented Feb 10, 2025

CLA assistant check
All committers have signed the CLA.

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.

1 participant