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

Optimize findAccessKey #8

Merged
merged 4 commits into from
Dec 13, 2018
Merged

Optimize findAccessKey #8

merged 4 commits into from
Dec 13, 2018

Conversation

fortuna
Copy link

@fortuna fortuna commented Dec 13, 2018

With this change, we spend half the CPU and allocate 1/20 of the memory, with half the number of allocations. Note how TCP and UDP are quite on par after the change.

Before:

BenchmarkTCPFindCipher-12    	    1000	   2441318 ns/op	 2026527 B/op	    3013 allocs/op
BenchmarkUDPUnpack-12        	    2000	    919961 ns/op	  125024 B/op	    1701 allocs/op

After:

BenchmarkTCPFindCipher-12    	    1000	   1353308 ns/op	  125268 B/op	    1705 allocs/op
BenchmarkUDPUnpack-12        	    2000	    890936 ns/op	  125029 B/op	    1701 allocs/op

The optimization required dealing with low level parts of the protocol. I'm happy to explain it in person.

Copy link

@trevj trevj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with the protocol at this level but it's hard to argue with those numbers.

@fortuna fortuna merged commit 7be8e4e into master Dec 13, 2018
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