<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/valkey-a-new-hash-table-ttqfxe6nf" -->

---
title: Valkey · A new hash table | daily.dev
description: Valkey 8.1 introduces a new hash table design replacing the old chained 'dict' structure, aimed at reducing memory usage and improving performance. The new...
canonical: https://daily.dev/posts/valkey-a-new-hash-table-ttqfxe6nf
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Valkey · A new hash table | daily.dev
og:description: Valkey 8.1 introduces a new hash table design replacing the old chained 'dict' structure, aimed at reducing memory usage and improving performance. The new...
og:url: https://daily.dev/posts/valkey-a-new-hash-table-ttqfxe6nf
og:image: https://api.daily.dev/og/posts/TtqFxe6nf.png
og:image:alt: Valkey · A new hash table
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Valkey · A new hash table

**[Valkey](https://daily.dev/sources/valkey-blog)** · 7 min read · 0 upvotes · 0 comments

## Summary

Valkey 8.1 introduces a new hash table design replacing the old chained 'dict' structure, aimed at reducing memory usage and improving performance. The new design uses 64-byte cache-line-sized buckets holding up to seven elements, embeds key-value data directly in serverObject (eliminating the dictEntry pointer), and uses an 8-byte metadata section with secondary hash bits to speed up lookups while minimizing memory accesses. Results show roughly 20 bytes saved per key-value pair (30 bytes for keys with TTL), and 10-20 bytes saved per element for Hashes, Sets, and Sorted Sets.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://valkey.io/blog/new-hash-table>

## Questions this post answers

### What changed in Valkey 8.1's hash table implementation compared to the old dict structure?

Valkey 8.1 replaced the chained 'dict' hash table with a new design using 64-byte buckets aligned to CPU cache lines, each holding up to seven elements. It eliminates the dictEntry structure by embedding keys and values directly in serverObject, cutting memory lookups from four to two per key access and reducing memory usage by about 20 bytes per key-value pair (30 bytes for keys with TTL).

_See daily.dev for more on database internals when evaluating storage engine upgrades like this._

### How does Valkey's new hash table use a secondary hash to speed up lookups?

Each 64-byte bucket in Valkey's new hash table reserves 7 bytes of metadata for a one-byte secondary hash per stored entry, derived from the 8 hash bits not used for bucket lookup. This lets the table skip mismatched entries without comparing full keys, eliminating about 99.6% of false positives and avoiding extra memory accesses per collision.

_Developers optimizing lookup-heavy data structures can track designs like this via daily.dev._

### Why didn't Valkey just use an existing hash table implementation like Swiss tables?

Valkey needed features that off-the-shelf implementations like Swiss tables don't provide: incremental rehashing so resizing doesn't freeze the server, a scan mechanism that works correctly even while the table is being resized (to support the SCAN command), and random element sampling to support commands like RANDOMKEY.

_daily.dev helps engineers weighing build-vs-adopt tradeoffs for core data structures like this._

## Similar posts on daily.dev

- [Valkey Memory Optimization, Version by Version and Encoding: How Many Bytes Did Each Release Actually Save?](https://daily.dev/posts/valkey-memory-optimization-version-by-version-and-encoding-how-many-bytes-did-each-release-actuall-5irzo7vsj) · Percona Blog · 1 upvotes · 0 comments
- [Valkey · Reducing Memory Overhead in Valkey 9.1](https://daily.dev/posts/valkey-reducing-memory-overhead-in-valkey-9-1-71iizc4rp) · Valkey · 10 upvotes · 0 comments
- [\[Video Podcast\] Improving Valkey with Madelyn Olson](https://daily.dev/posts/video-podcast-improving-valkey-with-madelyn-olson-bjpwcn9zl) · InfoQ · 0 upvotes · 0 comments
- [Valkey 9.1 Delivers More Performance & Enhanced Security](https://daily.dev/posts/valkey-9-1-delivers-more-performance-enhanced-security-9lzgcvzst) · Phoronix · 0 upvotes · 0 comments
- [Announcing Valkey 9.1 for Amazon ElastiCache](https://daily.dev/posts/announcing-valkey-9-1-for-amazon-elasticache-pvemznhnh) · AWS Database Blog · 0 upvotes · 0 comments

---

Tags: [#performance](https://daily.dev/tags/performance), [#redis](https://daily.dev/tags/redis), [#data-structures](https://daily.dev/tags/data-structures), [#valkey](https://daily.dev/tags/valkey)

[View this post on daily.dev](https://daily.dev/posts/valkey-a-new-hash-table-ttqfxe6nf)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Valkey · A new hash table","url":"https://daily.dev/posts/valkey-a-new-hash-table-ttqfxe6nf","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/valkey-a-new-hash-table-ttqfxe6nf"},"datePublished":"2026-08-23T12:23:10.802Z","dateModified":"2026-08-23T12:52:56.217Z","description":"Valkey 8.1 introduces a new hash table design replacing the old chained 'dict' structure, aimed at reducing memory usage and improving performance. The new...","image":"https://media.daily.dev/image/upload/s--2-1xRawN--/f_auto/v1722860399/public/Placeholder%2011","thumbnailUrl":"https://media.daily.dev/image/upload/s--2-1xRawN--/f_auto/v1722860399/public/Placeholder%2011","isAccessibleForFree":true,"articleSection":"Valkey","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Valkey","logo":"https://media.daily.dev/image/upload/s--XXPzEmD8--/f_auto,q_auto/v1787487496/logos/valkey-blog?_a=BAMAMicg0","url":"https://daily.dev/sources/valkey-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/valkey-a-new-hash-table-ttqfxe6nf","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"performance,redis,data-structures,valkey","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Valkey","item":"https://daily.dev/sources/valkey-blog"},{"@type":"ListItem","position":3,"name":"Valkey · A new hash table"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/valkey-a-new-hash-table-ttqfxe6nf#faq","mainEntity":[{"@type":"Question","name":"What changed in Valkey 8.1's hash table implementation compared to the old dict structure?","acceptedAnswer":{"@type":"Answer","text":"Valkey 8.1 replaced the chained 'dict' hash table with a new design using 64-byte buckets aligned to CPU cache lines, each holding up to seven elements. It eliminates the dictEntry structure by embedding keys and values directly in serverObject, cutting memory lookups from four to two per key access and reducing memory usage by about 20 bytes per key-value pair (30 bytes for keys with TTL). See daily.dev for more on database internals when evaluating storage engine upgrades like this."}},{"@type":"Question","name":"How does Valkey's new hash table use a secondary hash to speed up lookups?","acceptedAnswer":{"@type":"Answer","text":"Each 64-byte bucket in Valkey's new hash table reserves 7 bytes of metadata for a one-byte secondary hash per stored entry, derived from the 8 hash bits not used for bucket lookup. This lets the table skip mismatched entries without comparing full keys, eliminating about 99.6% of false positives and avoiding extra memory accesses per collision. Developers optimizing lookup-heavy data structures can track designs like this via daily.dev."}},{"@type":"Question","name":"Why didn't Valkey just use an existing hash table implementation like Swiss tables?","acceptedAnswer":{"@type":"Answer","text":"Valkey needed features that off-the-shelf implementations like Swiss tables don't provide: incremental rehashing so resizing doesn't freeze the server, a scan mechanism that works correctly even while the table is being resized (to support the SCAN command), and random element sampling to support commands like RANDOMKEY. daily.dev helps engineers weighing build-vs-adopt tradeoffs for core data structures like this."}}]}
```

