I'm currently doing a performance test for b+tree vs. ordinary-balanced-tree on disk file operations(maybe a kind of dbms) in C. b+tree is expected to be faster than bbst because it performs fewer disk I/O operations. But I found that, after some testing, the system is doing caching for the disk files, the file was entirely saved in memory(my memory size is 32GB)! b+tree can by no means be faster than bbst because no disk I/O will be performed. So I wonder if there is a way to disable system caching so that b+tree will win in perf? I've tried open the file with O_DIRECT|O_SYNC:
int fd = Open("sb.dat", O_DIRECT|O_SYNC|O_CREAT|O_RDWR, S_IRWXU|S_IRWXG|S_IRWXO);
but it seems not work.
Here is some info provided by getrusage()
page reclaims: 1359821
page faults: 9
AFAIK the kernel will still cache blocks from the disk even when you use O_DIRECT
, you could drop the kernel cache but this only works the first time:
echo 3 > /proc/sys/vm/drop_caches
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With