alluxio icon indicating copy to clipboard operation
alluxio copied to clipboard

Add microbenchmarks for multiple implementations of BlockStore

Open YangchenYe323 opened this issue 2 years ago • 4 comments

What changes are proposed in this pull request?

Added a benchmark suite to compare the performance between MonoBlockStore and PagedBlockStore

Why are the changes needed?

Provide insights on the micro performance characteristic for the PagedBlockStore that is under development.

Does this PR introduce any user facing changes?

No

YangchenYe323 avatar Aug 10 '22 04:08 YangchenYe323

@dbw9580 Would you like to take a look at this? Thanks!

YangchenYe323 avatar Aug 10 '22 05:08 YangchenYe323

Screen Shot 2022-08-11 at 12 35 35 AM An experimental run on my laptop.

YangchenYe323 avatar Aug 11 '22 01:08 YangchenYe323

Screen Shot 2022-08-11 at 12 35 35 AM An experimental run on my laptop.

I wonder why monoBlockStoreReadLocal is significantly slower than any other ones?

dbw9580 avatar Aug 11 '22 09:08 dbw9580

https://github.com/Alluxio/alluxio/blob/8f74e6584b6d2d71be3a3737057808b6f77c44ae/core/common/src/main/java/alluxio/worker/block/io/LocalFileBlockReader.java#L100

javadoc on java.nio.channels.FileChannel#mapsays

For most operating systems, mapping a file into memory is more expensive than reading or writing a few tens of kilobytes of data via the usual read and write methods. From the standpoint of performance it is generally only worth mapping relatively large files into memory.

looks like memory-mapping a file has a significant overhead... even for a file as large as 64MB.

dbw9580 avatar Aug 11 '22 09:08 dbw9580

It's surprising that monoBlockStoreReadLocal performance is so bad...

jja725 avatar Aug 11 '22 18:08 jja725

https://lkml.indiana.edu/hypermail/linux/kernel/0802.0/1496.html There's been discussions about performance issues of mmap. In general it seems that mmap brings significant overhead with like additional page fault, and could easily end up slower than normal read calls.

YangchenYe323 avatar Aug 11 '22 18:08 YangchenYe323

Screen Shot 2022-08-11 at 2 37 04 PM

Experimental run with page size as parameters.

YangchenYe323 avatar Aug 11 '22 18:08 YangchenYe323

I take a closer look at the mmap performance on Linux.

图片

Looks like there is quite a significant difference in perf between Linux and Mac.

My microbench is here https://gist.github.com/dbw9580/2bdb08ea6bf8e44e94a7f28c2d06155d

dbw9580 avatar Aug 12 '22 11:08 dbw9580

I take a closer look at the mmap performance on Linux.

图片

Looks like there is quite a significant difference in perf between Linux and Mac.

My microbench is here https://gist.github.com/dbw9580/2bdb08ea6bf8e44e94a7f28c2d06155d

Yeah my running suggests memory mapping is a lot slower on MacOS. Also, the current UnderFileSytemBlockReader uses a BufferedInputStream under the hood rather than a RandomAccessFile. That might be why readUfs could still be faster than readLocal.

YangchenYe323 avatar Aug 12 '22 15:08 YangchenYe323

Added an experimental run of Random Read results.

Random Read benchmark is conducted by:

  1. Parameters: BlockSize - size of the whole block; ReadSize - size of each read
  2. Randomly generate a sequence of offsets into the block, with invariant: NumOffsets * ReadSize = BlockSize (Each random read might overlap)
  3. For StoreBlockReader which is used for MonoBlockStore's local read, simulate random transferTo by positioning the raw FileChannel directly. No such methods exist for UnderFileSystemBlockReader and PagedBlockReader, so only read test for them. (Also the performance of monoBlockStoreRandTransferLocal is dubiously high)
Screen Shot 2022-08-16 at 2 52 55 PM

YangchenYe323 avatar Aug 16 '22 18:08 YangchenYe323

Great job! just post two flamecharts for paged read and transfer. transfer: (we could see extra buf write) CPU-flame-graph-pooled-transfer read: CPU-flame-graph-unpooled-read

beinan avatar Aug 17 '22 01:08 beinan

Benchmark results on Linux. Seems that MacOS does have particular issues with mmap Screen Shot 2022-08-17 at 1 01 10 AM Screen Shot 2022-08-17 at 1 01 28 AM

YangchenYe323 avatar Aug 17 '22 06:08 YangchenYe323

@dbw9580 Do you think this pr is good to merge now?

YangchenYe323 avatar Aug 18 '22 20:08 YangchenYe323

alluxio-bot, merge this please

beinan avatar Aug 30 '22 20:08 beinan