Skip to content

[CLEAN] Synthetic Benchmark PR #14595 - Hash - Unify Field-Value into a single struct along with dict no_value=1#17

Open
bar-qodo wants to merge 1 commit into
base_pr_14595_20260113_1673from
clean_pr_14595_20260113_1673
Open

[CLEAN] Synthetic Benchmark PR #14595 - Hash - Unify Field-Value into a single struct along with dict no_value=1#17
bar-qodo wants to merge 1 commit into
base_pr_14595_20260113_1673from
clean_pr_14595_20260113_1673

Conversation

@bar-qodo

Copy link
Copy Markdown

Benchmark PR redis#14595

Type: Clean (correct implementation)

Original PR Title: Hash - Unify Field-Value into a single struct along with dict no_value=1
Original PR Description: Introducing a new entry.c/h module that unifies field–value pairs with optional expiration into a single allocation. This effectively removes the need for the mstr structure. While mstr was highly generic and intended to support both data-type entries and key–value objects, its abstraction added complexity and incurred runtime overhead. This PR replaces it with a streamlined Entry layout defined by Valkey.

The new Entry struct supports two formats:

  • Embedded values for payloads ≤128 bytes
  • Pointer-based values for larger payloads

Expiration metadata is integrated directly into Entry to enable per-field expiration for hashes. Additionally, the hash data type’s dictionary is updated to operate with no_value=1. Few optimizations were introduced to prevent performance regressions. Overall, this is a substantial change to the hash data type, resulting in significantly reduced memory usage.

This implementation is based on Valkey PR (valkey-io/valkey#2089)
I adapted portions of the code related to entry structure.

Benchmark: c7i.4xlarge

The unified Entry design significantly reduces memory usage (30–50% savings) while maintaining stable performance. Minor throughput regressions in some write operations are outweighed by the substantial memory efficiency gains. This change represents a major improvement in memory efficiency with minimal performance tradeoffs.

SINGLE_HT_x: Hash operations (HSET/HGET/HDEL) with x-byte field values
HT_EX_x: Hash field expiration operations (HSETEX/HEXPIRE/HGETEX/HDEL) with x-second TTL

[numitems = 1000000, clients=2, threads=5]

                              Ops/sec_unify1  Ops/sec_unstable2  Ops/sec_diff_%  used_memory_unify1  used_memory_unstable2  used_memory_diff_%
Test          Step Cmd                                                                                                                        
HT_EX_1000    1    HSETEX          888176.69          969232.77            9.13            56377480               82606248               46.52
              2    HSETEX_AT       995277.80          997239.94            0.20            56378840               82611272               46.53
              3    HEXPIRE        1084515.18         1068388.85           -1.49            56419624               82652936               46.50
              4    HGETEX          988532.92          994231.07            0.58            56450304               82682592               46.47
              5    HDEL           3369171.21         3112296.00           -7.62              863504                 863408               -0.01
              
SINGLE_HT_10  1    HSET           1892748.18         2024483.29            6.96            46962344               65274952               38.99
              2    HGET           2129046.63         2184420.10            2.60            46988624               65301224               38.97
              3    HDEL           3434968.32         3470894.12            1.05              912432                 912408               -0.00
              
SINGLE_HT_30  1    HSET           1825128.26         1715089.65           -6.03            70908784               81301384               14.66
              2    HGET           2174599.93         2159791.76           -0.68            70908584               81301192               14.66
              3    HDEL           3508162.62         3442684.47           -1.87              911296                 912408                0.12
              
SINGLE_HT_100 1    HSET           1440710.86         1599805.21           11.04           142988856              161301464               12.81
              2    HGET           1872375.16         1805003.98           -3.60           142988696              161301280               12.81
              3    HDEL           3480351.50         3183746.08           -8.52              912408                 912416                0.00

[numitems = 2000000, clients=1, threads=1]

                              Ops/sec_unify1  Ops/sec_unstable2  Ops/sec_diff_%  used_memory_unify1  used_memory_unstable2  used_memory_diff_%
Test          Step Cmd                       
HT_EX_1000    1    HSETEX          898294.23          823122.50           -8.37           120135552              164681976               37.08
              2    HSETEX_AT       858850.13          969046.71           12.83           120070280              164610472               37.10
              3    HEXPIRE        1041995.00         1028178.25           -1.33           120123720              164664600               37.08
              4    HGETEX          955717.77          940873.18           -1.55           120129048              164670816               37.08
              5    HDEL           1625824.60         1537093.53           -5.46              911192                 911192                0.00
              
SINGLE_HT_2   1    HSET           1553021.71         1444716.13           -6.97            77068320              121688472               57.90
              2    HGET           1997762.51         1974078.38           -1.19            77092880              121713056               57.88
              3    HDEL           1912407.89         1827522.12           -4.44              935712                 935672               -0.00
              
SINGLE_HT_10  1    HSET           1503101.65         1379266.59           -8.24            93092696              137712872               47.93
              2    HGET           2012033.98         1843934.88           -8.35            93092664              137712840               47.93
              3    HDEL           1853379.17         1731364.89           -6.58              935496                 935496                0.00
              
SINGLE_HT_30  1    HSET           1410208.50         1367334.38           -3.04           141012696              169712872               20.35
              2    HGET           1908406.05         1877183.40           -1.64           141012664              169712840               20.35
              3    HDEL           1830005.32         1678321.21           -8.29              935496                 935512                0.00
              
SINGLE_HT_100 1    HSET           1168158.11         1145448.47           -1.94           285092696              329712872               15.65
              2    HGET           1718322.30         1631717.99           -5.04           285092640              329712824               15.65
              3    HDEL           1748959.59         1621381.48           -7.29              935496                 935488               -0.00

[numitems = 5000000, clients=1, threads=1]

                              Ops/sec_unify1  Ops/sec_unstable2  Ops/sec_diff_%  used_memory_unify1  used_memory_unstable2  used_memory_diff_%
Test          Step Cmd                       
HT_EX_1000    1    HSETEX          765705.70          693566.79           -9.42           365105848              469229824               28.52
              2    HSETEX_AT       781863.40          858107.03            9.75           327297032              435465136               33.05
              3    HEXPIRE         969147.76          968737.30           -0.04           327445600              435614448               33.03
              4    HGETEX          908009.72          906474.66           -0.17           327456240              435625248               33.03
              5    HDEL           1516803.91         1547503.24            2.02              935968                 935816               -0.02
              
SINGLE_HT_2   1    HSET           1344525.88         1236109.83           -8.06           248578152              373599392               50.29
              2    HGET           1509980.06         1518195.27            0.54           207796856              340044896               63.64
              3    HDEL           1705549.21         1776197.67            4.14              936072                 935816               -0.03
              
SINGLE_HT_10  1    HSET           1288319.45         1146623.83          -11.00           288578016              413599256               43.32
              2    HGET           1477099.64         1437135.52           -2.71           247796720              380044792               53.37
              3    HDEL           1755013.46         1726890.83           -1.60              935984                 935808               -0.02
              
SINGLE_HT_30  1    HSET           1215361.59         1139278.38           -6.26           408498016              493599408               20.83
              2    HGET           1438829.87         1421052.44           -1.24           367716720              460044960               25.11
              3    HDEL           1735006.25         1680705.04           -3.13              935968                 935984                0.00
              
SINGLE_HT_100 1    HSET           1042482.84          986722.66           -5.35           768578168              893599560               16.27
              2    HGET           1345565.78         1265776.00           -5.93           727796872              860045112               18.17
              3    HDEL           1694765.89         1639679.72           -3.25              936112                 936104               -0.00

Original PR URL: redis#14595

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants