Skip to content

Reading from stdin extremely slow #3281

Description

@Sp1l

Hi,

A user reported performance issues on the FreeBSD port of OpenSSL 1.1.0e using openssl enc. Investigating the issue, I found that reading stdin was extremely slow compared to using -in. This poor performance is not experienced with the 1.0.2 branch.

For reference and build options

$ /usr/local/bin/openssl speed aes-256-cbc
Doing aes-256 cbc for 3s on 16 size blocks: 10886156 aes-256 cbc's in 3.00s
Doing aes-256 cbc for 3s on 64 size blocks: 2878605 aes-256 cbc's in 3.01s
Doing aes-256 cbc for 3s on 256 size blocks: 727872 aes-256 cbc's in 3.00s
Doing aes-256 cbc for 3s on 1024 size blocks: 183097 aes-256 cbc's in 3.00s
Doing aes-256 cbc for 3s on 8192 size blocks: 22814 aes-256 cbc's in 3.00s
Doing aes-256 cbc for 3s on 16384 size blocks: 11369 aes-256 cbc's in 3.00s
OpenSSL 1.1.0e  16 Feb 2017
built on: reproducible build, date unspecified
options:bn(64,64) rc4(16x,int) des(int) aes(partial) blowfish(ptr)
compiler: cc -DDSO_DLFCN -DHAVE_DLFCN_H -DNDEBUG -DOPENSSL_THREADS -DOPENSSL_NO_STATIC_ENGINE -DOPENSSL_PIC -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DPADLOCK_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/usr/local/openssl\"" -DENGINESDIR="\"/usr/local/lib/engines-1.1\""
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 cbc      58059.50k    61250.73k    62111.74k    62497.11k    62297.43k    62089.90k
$  uname -a
FreeBSD build.brnrd.eu 11.0-RELEASE-p9 FreeBSD 11.0-RELEASE-p9 #0 r316824: Fri Apr 14 21:01:03 CEST 2017     bernard@build.brnrd.eu:/usr/obj/usr/src/sys/BEASTIE110  amd64
$  clang -v
FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0)
Target: x86_64-unknown-freebsd11.0
Thread model: posix
InstalledDir: /usr/bin

Created a 512M test file from /dev/zero named test.zero

$ dd if=/dev/zero bs=8m count=64 of=test.zero
64+0 records in
64+0 records out
536870912 bytes transferred in 0.363638 secs (1476389339 bytes/sec)

Using openssl internal read/write

$ time /usr/local/bin/openssl enc -e -aes-256-cbc -pass pass:fred -in test.zero -out /dev/null
1.29s user 0.17s system 99% cpu 1.457 total

Using internal read and stdout

$ time /usr/local/bin/openssl enc -e -aes-256-cbc -pass pass:fred -in test.zero > /dev/null
1.15s user 0.20s system 99% cpu 1.353 total

Using stdin and internal write (using dd so we have some statistics)

$ dd if=/dev/zero bs=8m count=64 | /usr/local/bin/openssl enc -e -chacha20 -pass pass:fred -out /dev/null
load: 1.32 cmd: openssl 14732 [running] 49.12r 8.31u 40.75s 100% 3632k
^C24+0 records in
22+2 records out
192937984 bytes transferred in 141.940640 secs (1359286 bytes/sec)
Killed after 140 seconds

Tested with -chacha20 as well with similar results.

Thanks for a great product!
Bernard Spil
Maintainer OpenSSL ports in FreeBSD

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions