Skip to content

Byte Array Benchmarks

Tomasz Edward Posluszny edited this page Oct 2, 2020 · 7 revisions

Passing byte arrays to and from JNI Motivation The benchmarks were done to improve performance of getting values for keys via Java API of RocksDB database. Environment Benchmarks were run on Windows 10 Home with Intel(R) Core(™) i7-6700K CPU with 4 cores and clock speed of 4GHz. The JVM version was as follows:

openjdk version "11.0.8" 2020-07-14 OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1) OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode) Methodology JMH Java harness was used to run the benchmarks. The benchmarks were running in SampleTime mode with a time unit set to nanosecond. There were 100 warm up iterations and 500 measurement iterations. The process of running all the benchmarks with above settings was repeated separately 10 times, which produced 10 CSV result files. The files were processed and the results were visualized using Python script with Pandas and Matplotlib libraries. Implementation There were two benchmark classes implemented: ByteArrayFromNativeBenchmark - to compare different options for writing byte arrays on native side and returning it to Java and ByteArrayToNativeBenchmark - to compare different options for passing byte array. There is a common part of code for all the benchmarks, which mocks getting data for the returned byte array:

std::string value = GetByteArrayInternal(key);

The function GetByteArrayInternal() copies the first 38 bytes of the input byte array and finds the return byte array in an std::unordered_map structure. Depending on the key, one of 6 different values can be returned with sizes as follows: 10, 50, 512, 1024, 4096 or 16384 bytes.

Clone this wiki locally