Skip to content

Instantly share code, notes, and snippets.

@wirepair
Created April 25, 2017 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wirepair/264404d0150282b78094cae4b25d0754 to your computer and use it in GitHub Desktop.
Save wirepair/264404d0150282b78094cae4b25d0754 to your computer and use it in GitHub Desktop.
modified chacha20 to do inline enc/dec with slice results.
original:
go test -count 1 -bench=Original -benchmem -memprofilerate=1 -memprofile=memoriginal.pprof
BenchmarkOriginal-8 1000000 25551 ns/op 41038.30 MB/s 592 B/op 13 allocs/op
(pprof) top10
565.58MB of 565.64MB total ( 100%)
Dropped 85 nodes (cum <= 2.83MB)
Showing top 10 nodes out of 11 (cum >= 565.58MB)
flat flat% sum% cum cum%
274.66MB 48.56% 48.56% 274.66MB 48.56% github.com/wirepair/chachazero/vendor/github.com/codahale/chacha20.NewWithRounds
122.07MB 21.58% 70.14% 396.73MB 70.14% github.com/wirepair/chachazero/vendor/github.com/codahale/chacha20poly1305.(*chacha20Key).initialize
91.55MB 16.19% 86.32% 91.55MB 16.19% github.com/wirepair/chachazero/vendor/github.com/codahale/chacha20poly1305.tag
76.22MB 13.47% 99.80% 320.36MB 56.64% github.com/wirepair/chachazero/vendor/github.com/codahale/chacha20poly1305.(*chacha20Key).Seal
1MB 0.18% 100% 565.58MB 100% github.com/wirepair/chachazero.BenchmarkOriginal
0.08MB 0.014% 100% 244.22MB 43.18% github.com/wirepair/chachazero/vendor/github.com/codahale/chacha20poly1305.(*chacha20Key).Open
0 0% 100% 564.58MB 99.81% github.com/wirepair/chachazero.original
0 0% 100% 274.66MB 48.56% github.com/wirepair/chachazero/vendor/github.com/codahale/chacha20.New
0 0% 100% 565.62MB 100% runtime.goexit
0 0% 100% 565.58MB 100% testing.(*B).run1.func1
inline:
go test -count 1 -bench=Inline -benchmem -memprofilerate=1 -memprofile=meminline.pprof
BenchmarkInline-8 1000000 20347 ns/op 51534.39 MB/s 544 B/op 9 allocs/op
(pprof) top10
519.80MB of 519.86MB total ( 100%)
Dropped 94 nodes (cum <= 2.60MB)
Showing top 10 nodes out of 11 (cum >= 519.80MB)
flat flat% sum% cum cum%
274.66MB 52.83% 52.83% 274.66MB 52.83% github.com/wirepair/chachazero/vendor/github.com/codahale/chacha20.NewWithRounds
122.07MB 23.48% 76.31% 396.73MB 76.31% github.com/wirepair/chachazero.(*chacha20Key).initialize
91.55MB 17.61% 93.93% 91.55MB 17.61% github.com/wirepair/chachazero.tag
30.52MB 5.87% 99.80% 274.66MB 52.83% github.com/wirepair/chachazero.(*chacha20Key).Seal
1MB 0.19% 100% 519.80MB 100% github.com/wirepair/chachazero.BenchmarkInline
0 0% 100% 244.14MB 46.96% github.com/wirepair/chachazero.(*chacha20Key).Open
0 0% 100% 518.80MB 99.80% github.com/wirepair/chachazero.inline
0 0% 100% 274.66MB 52.83% github.com/wirepair/chachazero/vendor/github.com/codahale/chacha20.New
0 0% 100% 519.84MB 100% runtime.goexit
0 0% 100% 519.80MB 100% testing.(*B).run1.func1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment