tink-crypto / tink

Tink is a multi-language, cross-platform, open source library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse.
https://developers.google.com/tink
Apache License 2.0
13.47k stars 1.18k forks source link

java tink library is not scaling with java threads #698

Closed uploeger closed 1 year ago

uploeger commented 1 year ago

It seems that java tink library does not scale with java threads. Find attached a small java test program.

Find below test results with one and three threads, running on a unix (redhat) box with 24 vCPUs.

In both cases around 1.000.000 encryption operations are executed every second. The amount of encryption operations is not increasing when using more threads.

java AeadThread encrypt "This is a test" 10000000 1 origtext: This is a test Thread: 1 for encryption loop: Mon Jun 12 10:49:25 CEST 2023 Thread: 1 after encryption loop: Mon Jun 12 10:49:34 CEST 2023

java AeadThread encrypt "This is a test" 10000000 3 origtext: This is a test Thread: 2 for encryption loop: Mon Jun 12 11:09:25 CEST 2023 Thread: 3 for encryption loop: Mon Jun 12 11:09:25 CEST 2023 Thread: 1 for encryption loop: Mon Jun 12 11:09:25 CEST 2023 Thread: 1 after encryption loop: Mon Jun 12 11:09:53 CEST 2023 Thread: 2 after encryption loop: Mon Jun 12 11:09:53 CEST 2023 Thread: 3 after encryption loop: Mon Jun 12 11:09:53 CEST 2023

test environment: java version: openjdk version "1.8.0_362" java tink library version: 1.9.0

Aead object is shared between threads.

AeadThread.zip

tholenst commented 1 year ago

This seems to be a duplicate of https://github.com/google/tink/issues/696. Please reply on my comments there.