On Mon, 2 Mar 2026 03:47:46 GMT, xinyangwu <[email protected]> wrote:

>> ### Summary
>> This PR introduces a parallel intrinsic for AES/ECB operations to replace 
>> the current per-block processing approach, reducing native call overhead and 
>> improving throughput for multi-block operations.
>> ### Problem
>> Except supporting AVX512, The existing AES/ECB implementation suffers from 
>> three major performance issues:
>> 1. Excessive stub call overhead: Each 16-byte block requires a separate 
>> intrinsic call, resulting in high invocation frequency
>> 
>> 2. Inefficient instruction-level parallelism: The serialized block 
>> processing fails to fully utilize instruction-level parallelism
>> 
>> 3. Redundant setup/teardown: Repeated initialization of encryption state for 
>> each block
>> ### Changes
>> Added parallel AES intrinsic implementation
>> ### Testing
>> JMH benchmarks
>> 
>> It can bring about a **37.43%** performance improvement.
>> 
>> On a Intel(R) Core(TM) i9-14900HX CPU machine with origin implements:
>> 
>> 
>> Benchmark     Mode  Cnt      Score    Error  Units
>> AesTest.test  avgt    5  11518.846 ± 68.621  ns/op
>> 
>> 
>> On the same machine with optimized implements:
>> 
>> 
>> Benchmark     Mode  Cnt     Score    Error  Units
>> AesTest.test  avgt    5  8381.499 ± 57.751  ns/op
>> 
>> 
>> All Tier-1 tests pass on linux-x64. This modification does not involve 
>> changing the encryption or decryption logic.
>
> xinyangwu has updated the pull request with a new target base due to a merge 
> or a rebase. The incremental webrev excludes the unrelated changes brought in 
> by the merge/rebase. The pull request contains 11 additional commits since 
> the last revision:
> 
>  - Remove trailing backslashes
>  - Merge branch 'openjdk:master' into aes
>  - refactor
>  - Merge branch 'openjdk:master' into aes
>  - 8376164: Optimize AES/ECB/PKCS5Padding implementation using full-message 
> intrinsic stub and parallel RoundKey addition
>  - Merge branch 'openjdk:master' into aes
>  - 8376164: Optimize AES/ECB/PKCS5Padding implementation using full-message 
> intrinsic stub and parallel RoundKey addition
>  - Merge branch 'openjdk:master' into aes
>  - Merge branch 'openjdk:master' into aes
>  - Merge branch 'openjdk:master' into aes
>  - ... and 1 more: https://git.openjdk.org/jdk/compare/1f0a47d3...ef2effbc

## Pull request overview

This PR introduces parallel intrinsic implementations for AES/ECB encryption 
and decryption operations to improve performance on x86_64 platforms that don't 
support AVX-512. The optimization processes 4 AES blocks at a time instead of 
individual blocks, reducing native call overhead and enabling better 
instruction-level parallelism.

**Changes:**
- Added two new parallel AES intrinsic implementations for ECB mode (encrypt 
and decrypt)
- Integrated the new implementations to be used on non-AVX512 platforms
- The implementations handle 128-bit, 192-bit, and 256-bit AES keys

### Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 
comment.

| File | Description |
| ---- | ----------- |
| src/hotspot/cpu/x86/stubGenerator_x86_64.hpp | Declares the two new 
multiblock parallel ECB functions |
| src/hotspot/cpu/x86/stubGenerator_x86_64_aes.cpp | Implements the parallel 
ECB encrypt/decrypt functions and registers them for non-AVX512 platforms |





---

💡 <a 
href="/openjdk/jdk/new/master/.github/instructions?filename=*.instructions.md" 
class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot 
custom instructions</a> for smarter, more guided reviews. <a 
href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot";
 class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how 
to get started</a>.

src/hotspot/cpu/x86/stubGenerator_x86_64_aes.cpp line 1407:

> 1405:   assert(UseAES, "need AES instructions and misaligned SSE support");
> 1406:   __ align(CodeEntryAlignment);
> 1407:   StubId stub_id = 
> StubId::stubgen_cipherBlockChaining_encryptAESCrypt_id;

The stub ID is incorrect. This function generates an electronicCodeBook encrypt 
stub, but uses stubgen_cipherBlockChaining_encryptAESCrypt_id instead of 
stubgen_electronicCodeBook_encryptAESCrypt_id. This should be changed to match 
the correct stub ID for this function.
Suggestion:

  StubId stub_id = StubId::stubgen_electronicCodeBook_encryptAESCrypt_id;

-------------

PR Review: https://git.openjdk.org/jdk/pull/29385#pullrequestreview-3697222883
PR Review Comment: https://git.openjdk.org/jdk/pull/29385#discussion_r2720966576

Reply via email to