redict/tests/unit
Roshan Khatri 5358bd7cdd
Reduce performance impact of dict rehashing and make it shorter. (#12899)
#### Problem Statement:
For any read/update operation during rehashing, we're doing ~10+ random
DRAM lookups to do the rehashing, as we are using the `rehashidx` to
rehash 10 buckets, whose dict entries most likely aren't cached in the
CPU or near the bucket we are operating on. If these random bucket are
empty, the rehashing process during that command execution is skipped.

#### Implementation:
For reducing the performance recession while dict is rehashing, we
determine the index at which the key would be stored in the 0th HT, we
check if that index has already been rehashed, if not we will rehash the
bucket containing the key and the bucket will be moved from 0th HT to
the 1st HT.

If the key has already been rehashed, we perform the random access
bucket rehash (using `rehashidx`) and we again verify if rehashing is
still ongoing and look up the key in the respective HT.

This ensures rehashing is not skipped in any command call and that we
rehash a particular bucket or random bucket in each call.

#### Changes in this PR:
- Added a new method `dictBucketRehash` to perform rehash on a single
bucket.
- Helper function `moveKeysInBucketOldtoNew` for `dictRehash` and
`dictBucketRehash` to move all the keys in a bucket from the old to the
new hash HT.
- Helper function `verifyMoreRehashRequired` for `dictRehash` and
`dictBucketRehash` to check if we have already rehashed the whole table
and if more rehashing is required.

### Benchmark:
- This PR still shows **~13%** improvement in the latency during
rehashing.

- Rehashing is now **~2%** faster for this PR when compared to unstable.

---------

Co-authored-by: Oran Agra <oran@redislabs.com>
Co-authored-by: Madelyn Olson <34459052+madolson@users.noreply.github.com>
2024-01-27 11:11:53 +02:00
..
cluster fix scripts access wrong slot if they disagree with pre-declared keys (#12906) 2024-01-15 09:57:12 +08:00
moduleapi Address some failures with new tests for improving debug report (#12915) 2024-01-08 17:56:06 -08:00
type Reduce performance impact of dict rehashing and make it shorter. (#12899) 2024-01-27 11:11:53 +02:00
acl-v2.tcl fix false success and a memory leak for ACL selector with bad parenthesis combination (#12452) 2023-08-02 10:46:06 +03:00
acl.tcl Exit early if slowlog/acllog max len set to zero (#12965) 2024-01-22 16:01:04 -08:00
aofrw.tcl Attempt to solve MacOS CI issues in GH Actions (#12013) 2023-04-12 09:19:21 +03:00
auth.tcl Fix race condition in tests/unit/auth.tcl (#12444) 2023-08-01 18:03:33 +03:00
bitfield.tcl Add BITFIELD_RO basic tests for non-repl use cases (#12187) 2023-05-18 12:16:46 +03:00
bitops.tcl BITCOUNT and BITPOS with non-existing key and illegal arguments should return error, not 0 (#11734) 2023-08-21 19:48:30 +03:00
client-eviction.tcl Attempt to solve MacOS CI issues in GH Actions (#12013) 2023-04-12 09:19:21 +03:00
dump.tcl Fix SPOP/RESTORE propagation when doing lazy free (#12320) 2023-06-16 08:14:11 -07:00
expire.tcl Fix DB iterator not resetting pauserehash causing dict being unable to rehash (#12757) 2023-11-14 14:28:46 +02:00
functions.tcl Some cleanups around function (#12940) 2024-01-23 14:26:33 +02:00
geo.tcl adding geo command edge cases tests (#12274) 2023-06-20 12:50:03 +03:00
hyperloglog.tcl Hyperloglog avoid allocate more than 'server.hll_sparse_max_bytes' bytes of memory for sparse representation (#11438) 2022-11-28 17:35:31 +02:00
info-command.tcl Make INFO command variadic (#6891) 2022-02-08 13:14:42 +02:00
info.tcl Add metric to INFO CLIENTS: pubsub_clients. (#12849) 2023-12-13 13:44:13 +08:00
introspection-2.tcl Fix possible crash in command getkeys (#12380) 2023-07-03 12:45:18 +03:00
introspection.tcl format cpu config as redis style (#7351) 2023-11-29 13:40:06 +08:00
keyspace.tcl Optimize KEYS when pattern includes hashtag and implies a single slot. (#12754) 2023-12-05 16:21:50 +02:00
latency-monitor.tcl Add printing for LATENCY related tests (#12514) 2023-08-27 11:42:55 +03:00
lazyfree.tcl attempt to fix tracking test issue with external tests due to lazy free (#9722) 2021-11-02 16:42:53 +02:00
limits.tcl Improve test suite to handle external servers better. (#9033) 2021-06-09 15:13:24 +03:00
maxmemory.tcl postpone the initialization of oject's lru&lfu until it is added to the db as a value object (#11626) 2023-05-24 09:40:11 +03:00
memefficiency.tcl re-enable defrag tests in cluster mode. (#12710) 2023-11-02 13:55:48 +02:00
multi.tcl multi.tcl: reset readraw at the end of the test (#12123) 2023-05-04 11:58:31 +03:00
networking.tcl Add reply_schema to command json files (internal for now) (#10273) 2023-03-11 10:14:16 +02:00
obuf-limits.tcl Add reply_schema to command json files (internal for now) (#10273) 2023-03-11 10:14:16 +02:00
oom-score-adj.tcl Fix oom-score-adj test due to no permission (#12887) 2023-12-27 08:42:46 +02:00
other.tcl Change the threshold of dict expand, shrink and rehash (#12948) 2024-01-19 17:00:43 +02:00
pause.tcl Bump codespell to 2.2.4, fix typos and outupdated comments (#11911) 2023-03-16 08:50:32 +02:00
printver.tcl Print version info before running the test 2011-05-20 11:44:54 +02:00
protocol.tcl Add reply_schema to command json files (internal for now) (#10273) 2023-03-11 10:14:16 +02:00
pubsub.tcl Fix broken protocol when PUBLISH emits local push inside MULTI (#12326) 2023-06-20 20:41:41 +03:00
pubsubshard.tcl Fix the bug that CLIENT REPLY OFF|SKIP cannot receive push notifications (#11875) 2023-03-12 17:50:44 +02:00
querybuf.tcl Pause cron to prevent premature shrinking in querybuf test (#12126) 2023-05-04 13:02:08 +03:00
quit.tcl flushSlavesOutputBuffers should not write to replicas scheduled to drop (#12242) 2023-06-12 14:05:34 +03:00
replybufsize.tcl Introduce debug command to disable reply buffer resizing (#10360) 2022-03-01 14:40:29 +02:00
scan.tcl Optimize SCAN with MATCH when pattern implies cluster slot (#12536) 2023-11-01 00:06:49 -07:00
scripting.tcl Allow running WAITAOF in scripts, remove NOSCRIPT flag (#12977) 2024-01-23 15:19:41 +02:00
shutdown.tcl Tests: Do not save an RDB by default and add a SIGTERM default AOFRW test (#12064) 2023-04-18 16:14:26 +03:00
slowlog.tcl Exit early if slowlog/acllog max len set to zero (#12965) 2024-01-22 16:01:04 -08:00
sort.tcl Support by/get options for sort(_ro) in cluster mode when pattern implies slot. (#12728) 2023-12-13 21:16:36 +02:00
tls.tcl Add support for reading encrypted keyfiles. (#8644) 2021-03-22 13:27:46 +02:00
tracking.tcl Bump codespell from 2.2.4 to 2.2.5 (#12557) 2023-09-08 16:10:17 +03:00
violations.tcl Run large-memory tests as solo. (#10626) 2022-04-24 17:29:35 +03:00
wait.tcl WAITAOF: Update fsynced_reploff_pending even if there's nothing to fsync (#12622) 2023-09-28 17:19:20 +03:00