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

feat: Aes algorithm hardware acceleration #190

Closed
wants to merge 2 commits into from

Conversation

driftluo
Copy link
Collaborator

@driftluo driftluo commented Oct 11, 2019

On my machine:

$ cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
      8  Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz

before:

1kb_aes128              time:   [9.4003 ms 9.4581 ms 9.5252 ms]                        
                        change: [+4.0887% +5.0088% +5.9171%] (p = 0.00 < 0.05)
                        Performance has regressed.
1kb_aes256              time:   [11.567 ms 11.638 ms 11.712 ms]                        
                        change: [+0.8615% +1.9225% +2.8798%] (p = 0.00 < 0.05)
                        Change within noise threshold.
1mb_aes128              time:   [36.289 ms 36.395 ms 36.521 ms]                        
Found 3 outliers among 100 measurements (3.00%)
  3 (3.00%) high mild
1mb_aes256              time:   [46.033 ms 46.292 ms 46.606 ms]                        
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild

after:

1kb_aes128              time:   [3.3078 ms 3.3222 ms 3.3390 ms]                        
                        change: [-65.736% -65.394% -65.066%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
  9 (9.00%) high mild
  1 (1.00%) high severe
1kb_aes256              time:   [3.5324 ms 3.5444 ms 3.5574 ms]                        
                        change: [-69.653% -69.430% -69.212%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
  3 (3.00%) high mild
  3 (3.00%) high severe
1mb_aes128              time:   [13.379 ms 13.430 ms 13.486 ms]                        
                        change: [-63.624% -63.383% -63.125%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
  5 (5.00%) high mild
  5 (5.00%) high severe
1mb_aes256              time:   [14.268 ms 14.306 ms 14.345 ms]                        
                        change: [-69.442% -69.242% -69.047%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild

@driftluo driftluo requested a review from a team October 11, 2019 11:01
@driftluo driftluo force-pushed the aes-algorithm-hardware-acceleration branch from 01a436e to cad1d87 Compare October 11, 2019 12:15
});

let enable = unsafe { AES_NI };
if enable {
Copy link

Choose a reason for hiding this comment

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

Is the enable needed, what's the problem of using AES_NI directly?

Copy link
Collaborator Author

@driftluo driftluo Oct 12, 2019

Choose a reason for hiding this comment

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

Just need an unsafe wrapper around AES_NI to get the value because AES_NI is mut.

I am thinking about whether to use a Cell<bool> or AtomicBool , so that the static variable does not need to be labeled mut

Copy link

Choose a reason for hiding this comment

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

I see. we could use lazy_static instead of INIT.call_once, in this way the mut could be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

lazy_static is Cell<T> and Once.

@driftluo
Copy link
Collaborator Author

Because of RustCrypto/stream-ciphers#12, I think we should follow industry standards.

I will switch all encryption related libraries to openssl and ring to ensure compliance with industry standards.

@driftluo driftluo closed this Oct 14, 2019
@driftluo driftluo deleted the aes-algorithm-hardware-acceleration branch October 15, 2019 02:38
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.

None yet

2 participants