reduce comparisons by skiplist
reduce comparisons by skiplist

Summary:
Key comparison is the single largest CPU user for CPU-bound
workloads. This diff reduces the number of comparisons in two ways.

The first is that it moves predecessor array gathering from
FindGreaterOrEqual to FindLessThan, so that FindGreaterOrEqual can
return immediately if compare_ returns 0.  As part of this change I
moved the sequential insertion optimization into Insert, to remove the
undocumented (and smelly) requirement that prev must be equal to prev_
if it is non-null.

The second optimization is that all of the search functions skip calling
compare_ when moving to a lower level that has the same Next pointer.
With a branching factor of 4 we would expect this to happen 1/4 of
the time.

On a single-threaded CPU-bound workload (-benchmarks=fillrandom -threads=1
-batch_size=1 -memtablerep=skip_list -value_size=0 --num=1600000
-level0_slowdown_writes_trigger=9999 -level0_stop_writes_trigger=9999
-disable_auto_compactions --max_write_buffer_number=8
-max_background_flushes=8 --disable_wal --write_buffer_size=160000000)
on my dev server this is good for a 7% perf win.

Test Plan: unit tests

Reviewers: rven, ljin, yhchiang, sdong, igor

Reviewed By: igor

Subscribers: dhruba

Differential Revision: https://reviews.facebook.net/D43233

Andymic/rocksdb,facebook/rocksdb,wlqGit/rocksdb,Andymic/rocksdb,wat-ze-hex/rocksdb,OverlordQ/rocksdb,jalexanderqed/rocksdb,OverlordQ/rocksdb,flabby/rocksdb,vmx/rocksdb,bbiao/rocksdb,ryneli/rocksdb,dkorolev/rocksdb,flabby/rocksdb,vmx/rocksdb,sorphi/rocksdb,JoeWoo/rocksdb,jalexanderqed/rocksdb,sorphi/rocksdb,makelivedotnet/rocksdb,luckywhu/rocksdb,jalexanderqed/rocksdb,bbiao/rocksdb,bbiao/rocksdb,lgscofield/rocksdb,siddhartharay007/rocksdb,vashstorm/rocksdb,temicai/rocksdb,hobinyoon/rocksdb,biddyweb/rocksdb,vashstorm/rocksdb,makelivedotnet/rocksdb,sorphi/rocksdb,wenduo/rocksdb,tsheasha/rocksdb,RyanTech/rocksdb,flabby/rocksdb,SunguckLee/RocksDB,wlqGit/rocksdb,tsheasha/rocksdb,Vaisman/rocksdb,wat-ze-hex/rocksdb,Applied-Duality/rocksdb,kaschaeffer/rocksdb,Applied-Duality/rocksdb,bbiao/rocksdb,bbiao/rocksdb,SunguckLee/RocksDB,JohnPJenkins/rocksdb,biddyweb/rocksdb,norton/rocksdb,ryneli/rocksdb,lgscofield/rocksdb,tsheasha/rocksdb,wenduo/rocksdb,dkorolev/rocksdb,hobinyoon/rocksdb,Applied-Duality/rocksdb,makelivedotnet/rocksdb,OverlordQ/rocksdb,jalexanderqed/rocksdb,caijieming-baidu/rocksdb,bbiao/rocksdb,vashstorm/rocksdb,wenduo/rocksdb,caijieming-baidu/rocksdb,geraldoandradee/rocksdb,SunguckLee/RocksDB,makelivedotnet/rocksdb,geraldoandradee/rocksdb,dkorolev/rocksdb,JohnPJenkins/rocksdb,temicai/rocksdb,vmx/rocksdb,biddyweb/rocksdb,makelivedotnet/rocksdb,JackLian/rocksdb,biddyweb/rocksdb,SunguckLee/RocksDB,biddyweb/rocksdb,dkorolev/rocksdb,Vaisman/rocksdb,facebook/rocksdb,SunguckLee/RocksDB,Andymic/rocksdb,makelivedotnet/rocksdb,sorphi/rocksdb,vashstorm/rocksdb,caijieming-baidu/rocksdb,luckywhu/rocksdb,vmx/rocksdb,RyanTech/rocksdb,wat-ze-hex/rocksdb,vmx/rocksdb,facebook/rocksdb,kaschaeffer/rocksdb,Vaisman/rocksdb,wlqGit/rocksdb,sorphi/rocksdb,hobinyoon/rocksdb,ryneli/rocksdb,JohnPJenkins/rocksdb,wlqGit/rocksdb,kaschaeffer/rocksdb,tsheasha/rocksdb,RyanTech/rocksdb,norton/rocksdb,Vaisman/rocksdb,hobinyoon/rocksdb,siddhartharay007/rocksdb,geraldoandradee/rocksdb,hobinyoon/rocksdb,facebook/rocksdb,lgscofield/rocksdb,wat-ze-hex/rocksdb,RyanTech/rocksdb,wat-ze-hex/rocksdb,sorphi/rocksdb,dkorolev/rocksdb,vmx/rocksdb,wat-ze-hex/rocksdb,geraldoandradee/rocksdb,tsheasha/rocksdb,JoeWoo/rocksdb,wat-ze-hex/rocksdb,wenduo/rocksdb,siddhartharay007/rocksdb,luckywhu/rocksdb,jalexanderqed/rocksdb,ryneli/rocksdb,JoeWoo/rocksdb,wlqGit/rocksdb,lgscofield/rocksdb,bbiao/rocksdb,bbiao/rocksdb,wat-ze-hex/rocksdb,OverlordQ/rocksdb,ryneli/rocksdb,siddhartharay007/rocksdb,JackLian/rocksdb,JoeWoo/rocksdb,Applied-Duality/rocksdb,wlqGit/rocksdb,Andymic/rocksdb,kaschaeffer/rocksdb,wenduo/rocksdb,temicai/rocksdb,temicai/rocksdb,hobinyoon/rocksdb,vashstorm/rocksdb,lgscofield/rocksdb,temicai/rocksdb,JohnPJenkins/rocksdb,SunguckLee/RocksDB,tsheasha/rocksdb,norton/rocksdb,wenduo/rocksdb,facebook/rocksdb,luckywhu/rocksdb,caijieming-baidu/rocksdb,JoeWoo/rocksdb,geraldoandradee/rocksdb,OverlordQ/rocksdb,wlqGit/rocksdb,luckywhu/rocksdb,ryneli/rocksdb,facebook/rocksdb,SunguckLee/RocksDB,OverlordQ/rocksdb,Andymic/rocksdb,temicai/rocksdb,caijieming-baidu/rocksdb,RyanTech/rocksdb,Andymic/rocksdb,lgscofield/rocksdb,jalexanderqed/rocksdb,flabby/rocksdb,tsheasha/rocksdb,JackLian/rocksdb,RyanTech/rocksdb,vmx/rocksdb,facebook/rocksdb,JoeWoo/rocksdb,Andymic/rocksdb,facebook/rocksdb,kaschaeffer/rocksdb,caijieming-baidu/rocksdb,SunguckLee/RocksDB,JohnPJenkins/rocksdb,vmx/rocksdb,biddyweb/rocksdb,dkorolev/rocksdb,vashstorm/rocksdb,siddhartharay007/rocksdb,Vaisman/rocksdb,flabby/rocksdb,flabby/rocksdb,JackLian/rocksdb,norton/rocksdb,kaschaeffer/rocksdb,sorphi/rocksdb,flabby/rocksdb,tsheasha/rocksdb,luckywhu/rocksdb,dkorolev/rocksdb,geraldoandradee/rocksdb,kaschaeffer/rocksdb,JackLian/rocksdb,JackLian/rocksdb,makelivedotnet/rocksdb,siddhartharay007/rocksdb,wenduo/rocksdb,JohnPJenkins/rocksdb,norton/rocksdb,temicai/rocksdb,jalexanderqed/rocksdb,caijieming-baidu/rocksdb,norton/rocksdb,vashstorm/rocksdb,luckywhu/rocksdb,Applied-Duality/rocksdb,norton/rocksdb,Applied-Duality/rocksdb,siddhartharay007/rocksdb,norton/rocksdb,lgscofield/rocksdb,Andymic/rocksdb,OverlordQ/rocksdb,JackLian/rocksdb,ryneli/rocksdb,wenduo/rocksdb,geraldoandradee/rocksdb,Vaisman/rocksdb,JohnPJenkins/rocksdb,Applied-Duality/rocksdb,hobinyoon/rocksdb,Vaisman/rocksdb,hobinyoon/rocksdb,JoeWoo/rocksdb,biddyweb/rocksdb,RyanTech/rocksdb