Add an optimized assembly implementation of AES for GOARCH=arm.#117
Open
jwgcarlson wants to merge 2 commits into
Open
Add an optimized assembly implementation of AES for GOARCH=arm.#117jwgcarlson wants to merge 2 commits into
GOARCH=arm.#117jwgcarlson wants to merge 2 commits into
Conversation
Untested. Some further work required.
The assembly in `encryptBlockAsm` now reads more like the pure Go implementation in `crypto/aes.encryptBlockGo`. Other small improvements: - Use register `R11`, which is usually reserved by the Go linker. This avoids the need to push/pop `COUNT` from the stack. - Rationalize register assignment, rather than the seemingly random choices from before. This just feels better. - Load/store whole words from `SRC`/`DST`, rather than one byte at a time. This assumes we're running in little-endian mode, but Go is already making that assumption for `GOARCH=arm`. - Re-use constant table from `crypto/aes.sbox0`, rather than re-defining our own. (We still have our own `dtable`, since Go's `te0`-`te3` were computed for big-endian implementations.)
hiszpanski
approved these changes
Apr 14, 2020
hiszpanski
left a comment
Member
There was a problem hiding this comment.
This looks like great work, something I think that would be worthwhile to try and merge upstream to Golang itself.
| @@ -0,0 +1,403 @@ | |||
| // +build arm | |||
Member
There was a problem hiding this comment.
Is this for arm-only or also for arm64?
Collaborator
Author
There was a problem hiding this comment.
Only arm. The Go standard library already has assembly implementations for arm64.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tested on an RPi Zero. Overall CPU usage for
alohartcdwent down when streaming to one peer, from ~26% to ~21%.