mirror of https://github.com/facebook/rocksdb.git
Small CPU optimization in InlineSkipList::Insert() (#12975)
Summary: reuse decode key in more places to avoid decoding length prefixed key x->Key(). Pull Request resolved: https://github.com/facebook/rocksdb/pull/12975 Test Plan: ran benchmarks simultaneously for "before" and "after" * fillseq: ``` (for I in $(seq 1 50); do ./db_bench --benchmarks=fillseq --disable_auto_compactions=1 --min_write_buffer_number_to_merge=100 --max_write_buffer_number=1000 --write_buffer_size=268435456 --num=5000000 --seed=1723056275 --disable_wal=1 2>&1 | grep "fillseq" done;) | awk '{ t += $5; c++; print } END { printf ("%9.3f\n", 1.0 * t / c) }'; before: 1483191 after: 1490555 (+0.5%) ``` * fillrandom: ``` (for I in $(seq 1 2); do ./db_bench_imain --benchmarks=fillrandom --disable_auto_compactions=1 --min_write_buffer_number_to_merge=100 --max_write_buffer_number=1000 --write_buffer_size=268435456 --num=2500000 --seed=1723056275 --disable_wal=1 2>&1 | grep "fillrandom" before: 255463 after: 256128 (+0.26%) ``` Reviewed By: anand1976 Differential Revision: D61835340 Pulled By: cbi42 fbshipit-source-id: 70345510720e348bacd51269acb5d2dd5a62bf0a
This commit is contained in:
parent
f31b4d80ff
commit
92ad4a88f3
|
@ -969,12 +969,12 @@ bool InlineSkipList<Comparator>::Insert(const char* key, Splice* splice,
|
||||||
while (true) {
|
while (true) {
|
||||||
// Checking for duplicate keys on the level 0 is sufficient
|
// Checking for duplicate keys on the level 0 is sufficient
|
||||||
if (UNLIKELY(i == 0 && splice->next_[i] != nullptr &&
|
if (UNLIKELY(i == 0 && splice->next_[i] != nullptr &&
|
||||||
compare_(x->Key(), splice->next_[i]->Key()) >= 0)) {
|
compare_(splice->next_[i]->Key(), key_decoded) <= 0)) {
|
||||||
// duplicate key
|
// duplicate key
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (UNLIKELY(i == 0 && splice->prev_[i] != head_ &&
|
if (UNLIKELY(i == 0 && splice->prev_[i] != head_ &&
|
||||||
compare_(splice->prev_[i]->Key(), x->Key()) >= 0)) {
|
compare_(splice->prev_[i]->Key(), key_decoded) >= 0)) {
|
||||||
// duplicate key
|
// duplicate key
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1012,12 +1012,12 @@ bool InlineSkipList<Comparator>::Insert(const char* key, Splice* splice,
|
||||||
}
|
}
|
||||||
// Checking for duplicate keys on the level 0 is sufficient
|
// Checking for duplicate keys on the level 0 is sufficient
|
||||||
if (UNLIKELY(i == 0 && splice->next_[i] != nullptr &&
|
if (UNLIKELY(i == 0 && splice->next_[i] != nullptr &&
|
||||||
compare_(x->Key(), splice->next_[i]->Key()) >= 0)) {
|
compare_(splice->next_[i]->Key(), key_decoded) <= 0)) {
|
||||||
// duplicate key
|
// duplicate key
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (UNLIKELY(i == 0 && splice->prev_[i] != head_ &&
|
if (UNLIKELY(i == 0 && splice->prev_[i] != head_ &&
|
||||||
compare_(splice->prev_[i]->Key(), x->Key()) >= 0)) {
|
compare_(splice->prev_[i]->Key(), key_decoded) >= 0)) {
|
||||||
// duplicate key
|
// duplicate key
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue