This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROCESSOR-SDK-AM62X: opnessl使用硬件引擎devcrypto进行加密操作,比不使用硬件引擎加密时间更长、CPU使用率更高

Part Number: PROCESSOR-SDK-AM62X

目前在AM62X平台发现opnessl使用硬件引擎devcrypto进行加密操作,比不使用硬件引擎加密时间更长、CPU使用率更高。

不使用硬件引擎,对aes-128-cbc算法进行测速测试,并使用该算法对一个200多M的文件加密测试,输出如下:

root@starcharge:/media/mmcblk0p1#  time -v openssl speed -evp aes-128-cbc
...

The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
AES-128-CBC      91351.90k   282958.93k   574506.89k   815835.14k   934024.99k   940124.84k
        Command being timed: "openssl speed -evp aes-128-cbc"
        User time (seconds): 17.98
        System time (seconds): 0.01
        Percent of CPU this job got: 99%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 18.02s
...

root@starcharge:/media/mmcblk0p1# time -v openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456
*** WARNING : deprecated key derivation used.
Using -iter or -pbkdf2 would be better.
        Command being timed: "openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456"
        User time (seconds): 0.60
        System time (seconds): 2.13
        Percent of CPU this job got: 14%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 19.50s

root@starcharge:/media/mmcblk0p1# time -v openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456
*** WARNING : deprecated key derivation used.
Using -iter or -pbkdf2 would be better.
        Command being timed: "openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456"
        User time (seconds): 0.49
        System time (seconds): 2.23
        Percent of CPU this job got: 13%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 19.53s

使用硬件引擎,对aes-128-cbc算法进行测试,并使用该算法对一个200多M的文件加密,输出如下:

root@starcharge:/media/mmcblk0p1#  time -v openssl speed -evp aes-128-cbc -engine devcrypto
Engine "devcrypto" set.
...
The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
AES-128-CBC      15280.00k    35717.33k   189169.78k  5755494.40k  8781004.80k 34666905.60k
        Command being timed: "openssl speed -evp aes-128-cbc -engine devcrypto"
        User time (seconds): 0.35
        System time (seconds): 7.46
        Percent of CPU this job got: 42%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 18.38s
...
root@starcharge:/media/mmcblk0p1# time -v openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456 -engine devcrypto
Engine "devcrypto" set.
*** WARNING : deprecated key derivation used.
Using -iter or -pbkdf2 would be better.
        Command being timed: "openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456 -engine devcrypto"
        User time (seconds): 0.76
        System time (seconds): 4.58
        Percent of CPU this job got: 24%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 21.78s
...
root@starcharge:/media/mmcblk0p1# time -v openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456 -engine devcrypto
Engine "devcrypto" set.
*** WARNING : deprecated key derivation used.
Using -iter or -pbkdf2 would be better.
        Command being timed: "openssl enc -aes-128-cbc -e -in file2.zip -out file2.zip.enc -k 123456 -engine devcrypto"
        User time (seconds): 0.71
        System time (seconds): 4.57
        Percent of CPU this job got: 22%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 23.10s

可以看出使用硬件引擎比不使用硬件引擎加密时间更长、CPU使用率更高。同步测试了使用sha256算法计算文件的散列值,也是一样的现象,请帮忙确定这是正常的吗?

  • 为您咨询了资深产品线工程师,这需要一些时间

  • 你好,请问有进展吗?

  • 您的测试使用的是哪个 SDK 版本?
    我们是否使用最新的 SDK 9.1 进行了测试?

  • 使用的是SDK 8.6,没有使用SDK9.1测试,目前在SDK8.6上发现:

    1、使用openssl speed命令来测试算法性能发现使用软件处理加密数据的速度是远大于硬件引擎加密卸载,使用硬件加速引擎只能降低CPU使用率:

    软件性能测试:
    root@starcharge:/# time -v openssl speed -elapsed -evp aes-128-cbc
    You have chosen to measure elapsed time instead of user CPU time.
    Doing AES-128-CBC for 3s on 16 size blocks: 17071335 AES-128-CBC's in 3.00s
    Doing AES-128-CBC for 3s on 64 size blocks: 13264271 AES-128-CBC's in 3.00s
    Doing AES-128-CBC for 3s on 256 size blocks: 6709298 AES-128-CBC's in 3.00s
    Doing AES-128-CBC for 3s on 1024 size blocks: 2390490 AES-128-CBC's in 3.00s
    Doing AES-128-CBC for 3s on 8192 size blocks: 340889 AES-128-CBC's in 3.00s
    Doing AES-128-CBC for 3s on 16384 size blocks: 172118 AES-128-CBC's in 3.00s
    <…snip…>
    The 'numbers' are in 1000s of bytes per second processed.
    type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
    AES-128-CBC      91047.12k   282971.11k   572526.76k   815953.92k   930854.23k   939993.77k
            Command being timed: "openssl speed -elapsed -evp aes-128-cbc"
            User time (seconds): 17.97
            System time (seconds): 0.01
            Percent of CPU this job got: 99%
            Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 18.02s
    Cryptodev性能测试:
    root@starcharge:/# time -v openssl speed -elapsed -evp aes-128-cbc -engine devcrypto
    Engine "devcrypto" set.
    You have chosen to measure elapsed time instead of user CPU time.
    Doing AES-128-CBC for 3s on 16 size blocks: 66902 AES-128-CBC's in 3.00s
    Doing AES-128-CBC for 3s on 64 size blocks: 66962 AES-128-CBC's in 3.00s
    Doing AES-128-CBC for 3s on 256 size blocks: 66367 AES-128-CBC's in 3.00s
    Doing AES-128-CBC for 3s on 1024 size blocks: 56521 AES-128-CBC's in 3.00s
    Doing AES-128-CBC for 3s on 8192 size blocks: 32450 AES-128-CBC's in 3.00s
    Doing AES-128-CBC for 3s on 16384 size blocks: 21079 AES-128-CBC's in 3.00s
    <…snip…>
    The 'numbers' are in 1000s of bytes per second processed.
    type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
    AES-128-CBC        356.81k     1428.52k     5663.32k    19292.50k    88610.13k   115119.45k
            Command being timed: "openssl speed -elapsed -evp aes-128-cbc -engine devcrypto"
            User time (seconds): 0.29
            System time (seconds): 7.52
            Percent of CPU this job got: 42%
            Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 18.37s

    2、使用openssl enc命令测试加密速度发现使用硬件引擎devcrypto进行加密操作,比不使用硬件引擎加密时间更长、CPU使用率更高,即描述列出。

    请问这种情况是正常的吗,请给出正常使用硬件引擎的性能数据。

  • 我们可以使用最新的 SDK 9.1 运行测试,看看是否有相同的观察结果?