V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
keyfunc
V2EX  ›  Apple

M1 跑 openssl speed 测试, rosetta 竟然速度快好多

  •  
  •   keyfunc · 2022-04-19 15:35:33 +08:00 · 2534 次点击
    这是一个创建于 978 天前的主题,其中的信息可能已经有所发展或是发生改变。

    这算逆优化么 😂

    结果:

    arch -arm64e openssl speed -evp aes-256-gcm

    LibreSSL 2.8.3
    built on: date not available
    options:bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) aes(partial) blowfish(idx) 
    compiler: information not available
    The 'numbers' are in 1000s of bytes per second processed.
    type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
    aes-256-gcm     143582.05k   146068.54k   143675.00k   143172.47k   143065.32k
    

    arch -x86_64 openssl speed -evp aes-256-gcm

    LibreSSL 2.8.3
    built on: date not available
    options:bn(64,64) rc4(16x,int) des(idx,cisc,16,int) aes(partial) blowfish(idx) 
    compiler: information not available
    The 'numbers' are in 1000s of bytes per second processed.
    type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
    aes-256-gcm     513189.06k  1466338.36k  1692859.34k  1656888.24k  1660308.10k
    
    第 1 条附言  ·  2022-04-19 16:17:19 +08:00
    OpenSSL 1.1.1n  15 Mar 2022
    built on: Tue Mar 15 14:37:47 2022 UTC
    options:bn(64,64) rc4(int) des(int) aes(partial) idea(int) blowfish(ptr) 
    compiler: clang -fPIC -arch arm64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -D_REENTRANT -DNDEBUG
    The 'numbers' are in 1000s of bytes per second processed.
    type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
    aes-256-gcm    1001410.93k  2674462.35k  4020612.61k  4051648.47k  3813676.37k  3968878.79k
    

    重新用 OpenSSL 跑了下,好像自带的 LibreSSL 有点问题

    第 2 条附言  ·  2022-04-19 17:22:51 +08:00

    原生情况下跑了 AES 128 GCM,这128和256差距也太大了吧

    arch -arm64e openssl speed -evp aes-128-gcm -multi 10

    LibreSSL 2.8.3
    built on: date not available
    options:bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) aes(partial) blowfish(idx) 
    compiler: information not available
    evp           17771871.76k 71601419.60k 287914482.61k 1148759522.20k 9167217710.93k
    
    

    arch -arm64e openssl speed -evp aes-128-gcm

    LibreSSL 2.8.3
    built on: date not available
    options:bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) aes(partial) blowfish(idx) 
    compiler: information not available
    The 'numbers' are in 1000s of bytes per second processed.
    type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
    aes-128-gcm    2219882.36k  8934119.25k 35553156.84k 142883225.35k 1141059247.03k
    
    7 条回复    2022-04-19 17:14:34 +08:00
    xtinput
        1
    xtinput  
       2022-04-19 15:37:42 +08:00
    我的 M1Max 和你这个数据差不多
    keyfunc
        2
    keyfunc  
    OP
       2022-04-19 16:16:17 +08:00
    ```
    OpenSSL 1.1.1n 15 Mar 2022
    built on: Tue Mar 15 14:37:47 2022 UTC
    options:bn(64,64) rc4(int) des(int) aes(partial) idea(int) blowfish(ptr)
    compiler: clang -fPIC -arch arm64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -D_REENTRANT -DNDEBUG
    The 'numbers' are in 1000s of bytes per second processed.
    type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
    aes-256-gcm 1001410.93k 2674462.35k 4020612.61k 4051648.47k 3813676.37k 3968878.79k
    ```

    重新用 OpenSSL 跑了下,好像自带的 LibreSSL 有点问题
    linusyang
        3
    linusyang  
       2022-04-19 16:32:13 +08:00 via iPhone
    LibreSSL 没有 arm64 的汇编优化,只有 x86_64 的。OpenSSL 的指令集优化多一点。
    xtinput
        4
    xtinput  
       2022-04-19 16:48:55 +08:00
    version: 3.0.2
    built on: Tue Mar 15 14:30:24 2022 UTC
    options: bn(64,64)
    compiler: clang -fPIC -arch arm64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -D_REENTRANT -DOPENSSL_BUILDING_OPENSSL -DNDEBUG
    CPUINFO: OPENSSL_armcap=0x7f
    The 'numbers' are in 1000s of bytes per second processed.
    type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
    AES-256-GCM 933194.39k 2587635.29k 4097587.80k 4664237.94k 5703328.13k 5812055.75k
    linusyang
        5
    linusyang  
       2022-04-19 16:58:46 +08:00 via iPhone
    另外可以用自带的试试 aes-128-gcm ,貌似有优化。
    MrKrabs
        6
    MrKrabs  
       2022-04-19 16:59:35 +08:00   ❤️ 1
    keyfunc
        7
    keyfunc  
    OP
       2022-04-19 17:14:34 +08:00
    @linusyang 是的,好像 128 很快,原生比 rosetta 快了,差距并不大
    LibreSSL rosetta
    aes-128-gcm 1531638.85k 5946102.75k 23789147.19k 95029256.18k 760820812.43k

    LibreSSL 原生
    aes-128-gcm 2220132.69k 8950815.61k 35738367.40k 143223969.26k 1145713507.08k

    OpenSSL
    aes-128-gcm 1129241.01k 3110185.88k 4705038.08k 4669664.39k 4536124.82k
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2726 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 09:18 · PVG 17:18 · LAX 01:18 · JFK 04:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.