45828c7215
Summary: Hello and thank you for RocksDB, While looking into the buffered io used when an `OPTIONS` file is read I noticed the `OPTIONS` files produced by RocksDB 5.8.8 (and head of master) were just over 4096 bytes in size, resulting in the version of glibc I am using (glibc-2.17-196.el7) (on the filesystem used) being passed a 4K buffer for the `fread_unlocked` call and 2 system call reads using a 4096 buffer being used to read the contents of the `OPTIONS` file. If the buffer size is increased to 8192 then 1 system call read is used to read the contents. As I think the buffer size is just used for reading `OPTIONS` files, and I thought it likely that `OPTIONS` files have increased in size (as more options are added), I thought I would suggest an increase. [ If the comments from the top of the `OPTIONS` file are removed, and white space from the start of lines is removed then the size can be reduced to be under 4K, but as more options are added the size seems likely to grow again. ] Create a new database: ``` > ./ldb --create_if_missing --db=/tmp/rdb_tmp put 1 1 OK ``` The OPTIONS file is 4252 bytes: ``` > stat /tmp/rdb_tmp/OPTIONS* | head -n 2 File: ‘/tmp/rdb_tmp/OPTIONS-000005’ Size: 4252 Blocks: 16 IO Block: 4096 regular file ``` Before, the 4096 byte buffer is used from 2 system read calls: ``` > strace -f ./ldb --try_load_options --db=/tmp/rdb_tmp get DOES_NOT_EXIST 2>&1 | grep -A 1 'RocksDB option file' read(3, "# This is a RocksDB option file."..., 4096) = 4096 read(3, "e\n metadata_block_size=4096\n c"..., 4096) = 156 ``` ltrace shows 4096 passed to fread_unlocked ``` > ltrace -S -f ./ldb --try_load_options --db=/tmp/rdb_tmp get DOES_NOT_EXIST 2>&1 | grep -C 3 'RocksDB option file' [pid 51013] fread_unlocked(0x7ffd5fbf2d50, 1, 4096, 0x7fd2e084e780 <unfinished ...> [pid 51013] fstat@SYS(3, 0x7ffd5fbf28f0) = 0 [pid 51013] mmap@SYS(nil, 4096, 3, 34, -1, 0) = 0x7fd2e318c000 [pid 51013] read@SYS(3, "# This is a RocksDB option file."..., 4096) = 4096 [pid 51013] <... fread_unlocked resumed> ) = 4096 ... ``` After, the 8192 byte buffer is used from 1 system read call: ``` > strace -f ./ldb --try_load_options --db=/tmp/rdb_tmp get DOES_NOT_EXIST 2>&1 | grep -A 1 'RocksDB option file' read(3, "# This is a RocksDB option file."..., 8192) = 4252 read(3, "", 4096) = 0 ``` ltrace shows 8192 passed to fread_unlocked ``` > ltrace -S -f ./ldb --try_load_options --db=/tmp/rdb_tmp get DOES_NOT_EXIST 2>&1 | grep -C 3 'RocksDB option file' [pid 146611] fread_unlocked(0x7ffcfba382f0, 1, 8192, 0x7fc4e844e780 <unfinished ...> [pid 146611] fstat@SYS(3, 0x7ffcfba380f0) = 0 [pid 146611] mmap@SYS(nil, 4096, 3, 34, -1, 0) = 0x7fc4eaee0000 [pid 146611] read@SYS(3, "# This is a RocksDB option file."..., 8192) = 4252 [pid 146611] read@SYS(3, "", 4096) = 0 [pid 146611] <... fread_unlocked resumed> ) = 4252 [pid 146611] feof(0x7fc4e844e780) = 1 ``` Closes https://github.com/facebook/rocksdb/pull/3294 Differential Revision: D6653684 Pulled By: ajkr fbshipit-source-id: 222f25f5442fefe1dcec18c700bd9e235bb63491 |
||
---|---|---|
.. | ||
cf_options.cc | ||
cf_options.h | ||
db_options.cc | ||
db_options.h | ||
options_helper.cc | ||
options_helper.h | ||
options_parser.cc | ||
options_parser.h | ||
options_sanity_check.cc | ||
options_sanity_check.h | ||
options_settable_test.cc | ||
options_test.cc | ||
options.cc |