AES-NI enhancements to NSS on Sandy Bridge systems



8 years ago
3 years ago


(Reporter: aleksey.v.ignatenko, Unassigned)



Firefox Tracking Flags

(Not tracked)



(3 attachments)



8 years ago
In Sandy Bridge, the AES round instructions have a throughput of one cycle and latency of eight cycles. Compared to the Westmere, where these instructions have throughput of two cycles and a latency of six cycles,  Sandy Bridge offers a two fold increase in the throughput, with some additional latency. As a result, the AES encryption/decryption throughput can be significantly increased, for parallel modes of operation (Intel® 64 and IA-32 Architectures Optimization Reference Manual, page 310, paragraph 2). 

In NSS, parallel mode is already implemented for eight blocks (it's optimum). But without loop unrolling, which also can increase results for CBC decrypt and ECB encrypt/decrypt for various key sizes. The bug contains implementation of unrolled version of CBC decrypt and ECB encrypt/decrypt.

Platforms: Sandy Bridge (RHEL 6, gcc 4.4.4), Westmere (RHEL 5.5, gcc 4.1.2).
NSS: Mozilla nss 3.12.11 with nspr 4.8.9.
JDK: b147-x64.
Microbenchmark: written on Java // warmup: 2 minutes; iteration: 3 minutes; score =  number of operations (CBC decrypt, ECB decrypt or ECB encrypt) / time iteration [ops/m].

Testing results: the results show performance improve on Sandy Bridge:

Ratio Unrolled/Original on 1 thread
Cipher/Key_Size	128-bit	192-bit	256-bit
CBC decrypt		1.238		1.247		1.297
ECB decrypt		1.280		1.320		1.300
ECB encrypt		1.185		1.212		1.165

Ratio Unrolled/Original on 4 threads
Cipher/Key Size	128-bit	192-bit	256-bit
CBC decrypt		1.201		1.242		1.277
ECB decrypt		1.228		1.293		1.269
ECB encrypt		1.160		1.170		1.151

There is no performance impact on Westmere platform.
Micro benchmark, intel-aes.s patch with loop unrolling and howto in attach.

Comment 1

8 years ago
Posted file Micro benchmark

Comment 2

8 years ago
Posted file howto


8 years ago
Keywords: perf

Comment 3

8 years ago
Link to Optimization Notice


7 years ago
Version: 3.12.11 → 3.13
Ever confirmed: true
Who needs to review this to move this along?

Any interdependency with bug 540986?

Comment 5

7 years ago
The enhancement proposed in this bug is for Linux only, #540986 is a port to  Windows and seems not to be related to Linux intel-aes implementation.


7 years ago
Attachment #577519 - Attachment is patch: true


7 years ago
Attachment #577519 - Flags: review?(rrelyea)

Comment 6

7 years ago
Comment on attachment 577519 [details] [diff] [review]
Enhancement patch

r+ rrelyea
Attachment #577519 - Flags: review?(rrelyea) → review+

Comment 7

7 years ago
Patch applied in the trunk: 
revision 1.7
date: 2012/05/03 00:51:37;  author:;  state: Exp;  lines: +1011 -159
Bug 706024 - AES-NI enhancements to NSS on Sandy Bridge system,, r=rrelyea


7 years ago
Last Resolved: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.