mirror of
https://github.com/fluencelabs/redis
synced 2025-04-01 15:21:03 +00:00
hllSparseAdd(): faster code removing conditional.
Bottleneck found profiling. Big run time improvement found when testing after the change.
This commit is contained in:
parent
4e0a99ba51
commit
db40da0a47
@ -202,7 +202,7 @@ struct hllhdr {
|
|||||||
#define HLL_SPARSE 1 /* Sparse encoding */
|
#define HLL_SPARSE 1 /* Sparse encoding */
|
||||||
#define HLL_MAX_ENCODING 1
|
#define HLL_MAX_ENCODING 1
|
||||||
|
|
||||||
#define HLL_SPARSE_MAX 3000
|
#define HLL_SPARSE_MAX 12000
|
||||||
|
|
||||||
/* =========================== Low level bit macros ========================= */
|
/* =========================== Low level bit macros ========================= */
|
||||||
|
|
||||||
@ -663,14 +663,23 @@ int hllSparseAdd(robj *o, unsigned char *ele, size_t elesize) {
|
|||||||
next = NULL; /* Points to the next opcode at the end of the loop. */
|
next = NULL; /* Points to the next opcode at the end of the loop. */
|
||||||
span = 0;
|
span = 0;
|
||||||
while(p < end) {
|
while(p < end) {
|
||||||
|
int oplen;
|
||||||
|
|
||||||
/* Set span to the number of registers covered by this opcode. */
|
/* Set span to the number of registers covered by this opcode. */
|
||||||
if (HLL_SPARSE_IS_ZERO(p)) span = HLL_SPARSE_ZERO_LEN(p);
|
if (HLL_SPARSE_IS_ZERO(p)) {
|
||||||
else if (HLL_SPARSE_IS_XZERO(p)) span = HLL_SPARSE_XZERO_LEN(p);
|
span = HLL_SPARSE_ZERO_LEN(p);
|
||||||
else span = HLL_SPARSE_VAL_LEN(p);
|
oplen = 1;
|
||||||
|
} else if (HLL_SPARSE_IS_XZERO(p)) {
|
||||||
|
span = HLL_SPARSE_XZERO_LEN(p);
|
||||||
|
oplen = 2;
|
||||||
|
} else {
|
||||||
|
span = HLL_SPARSE_VAL_LEN(p);
|
||||||
|
oplen = 1;
|
||||||
|
}
|
||||||
/* Break if this opcode covers the register as 'index'. */
|
/* Break if this opcode covers the register as 'index'. */
|
||||||
if (index <= first+span-1) break;
|
if (index <= first+span-1) break;
|
||||||
prev = p;
|
prev = p;
|
||||||
p += (HLL_SPARSE_IS_XZERO(p)) ? 2 : 1;
|
p += oplen;
|
||||||
first += span;
|
first += span;
|
||||||
}
|
}
|
||||||
if (span == 0) return -1; /* Invalid format. */
|
if (span == 0) return -1; /* Invalid format. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user