ColinChamber commented on code in PR #793:
URL: https://github.com/apache/incubator-kvrocks/pull/793#discussion_r957386691
##########
src/redis_bitmap.cc:
##########
@@ -146,16 +146,27 @@ rocksdb::Status Bitmap::GetString(const Slice &user_key,
const uint32_t max_btos
// If you setbit bit 0 1, the value is stored as 0x01 in Kvrocks but 0x80
in Redis.
// So we need to swap bits is to keep the same return value as Redis.
+ static const uint8_t swap_table[256] = {
Review Comment:
Yeah, the previous way is more readable. But doing these operations at
runtime is unnecessary and will significantly degrade performance.We can easily
use redis-benchmark for comparison.
e.g.
1. Write data at random offsets.
```sh
redis-benchmark -r 9000000 -n 200000 -h 127.0.0.1 -p 6666 eval 'local source
= ARGV[1];local offset,num = string.gsub(source,"0","");if(num == 12) then
offset = "0";end;return redis.call("setbit", "foo", offset, 1)' 0 __rand_int__
```
2. Get and compare QPS before and after optimization.
```sh
redis-benchmark -n 200 -h 127.0.0.1 -p 6666 eval 'return redis.call("get",
"foo")' 0
```
In my environment
**previous way : 53.30 requests per second**
**now : 80.39 requests per second**
We cannot ignore this performance gap. So I think the previous
implementation seems inappropriate, although no one complains. @git-hulk
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]