* Add more documentation about dashtable. Tune expiry heuristics a bit

* Minor lang change

* minor lng changes

Co-authored-by: Roman Gershman <romange@gmail.com>
This commit is contained in:
odedponcz 2022-05-22 09:46:49 +03:00 committed by GitHub
parent 3717079172
commit 869cd19897
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 13 deletions

View file

@ -12,28 +12,30 @@ A novel, Redis and Memcached compatible memory store.
## Background
Dragonfly started as an experiment to see what an in-memory datastore could look like if it was designed in 2022. Based on the lessons learned from our experience as users of memory stores and as engineers who worked in cloud companies, we knew that we need to preserve two key properties for Dragonfly: a) to provide atomicity guarantees for all its operations, and b) to guarantee low, sub-millisecond latency under very high throughput.
Dragonfly started as an experiment to see how an in-memory datastore could look like if it was designed in 2022. Based on lessons learned from our experience as users of memory stores and as engineers who worked for cloud companies, we knew that we need to preserve two key properties for Dragonfly: a) to provide atomicity guarantees for all its operations, and b) to guarantee low, sub-millisecond latency over very high throughput.
Our first challenge was how we fully utilize CPU, memory, and i/o resources on servers that are available today in public clouds. To solve it, we used [shared-nothing architecture](https://en.wikipedia.org/wiki/Shared-nothing_architecture), which allowed us to partition the keyspace of the memory store between threads, s.t., each thread would manage its own slice of dictionary data. We call these slices - shards. The library that powers thread and I/O management for shared-nothing architecture is open-sourced [here](https://github.com/romange/helio).
Our first challenge was how to fully utilize CPU, memory, and i/o resources using servers that are available today in public clouds. To solve this, we used [shared-nothing architecture](https://en.wikipedia.org/wiki/Shared-nothing_architecture), which allows us to partition the keyspace of the memory store between threads, so that each thread would manage its own slice of dictionary data. We call these slices - shards. The library that powers thread and I/O management for shared-nothing architecture is open-sourced [here](https://github.com/romange/helio).
To provide atomicity guarantees for multi-key operations, we used the advancements from recent academic research. We chose the paper ["VLL: a lock manager redesign for main memory database systems”](http://www.cs.umd.edu/~abadi/papers/vldbj-vll.pdf) to develop the transactional framework for Dragonfly. The choice of shared-nothing architecture and VLL allowed us to compose atomic multi-key operations without using mutexes or spinlocks. This was a major milestone for our PoC and its performance stood out from other commercial and open-source solutions.
To provide atomicity guarantees for multi-key operations, we used the advancements from recent academic research. We chose the paper ["VLL: a lock manager redesign for main memory database systems”](https://www.cs.umd.edu/~abadi/papers/vldbj-vll.pdf) to develop the transactional framework for Dragonfly. The choice of shared-nothing architecture and VLL allowed us to compose atomic multi-key operations without using mutexes or spinlocks. This was a major milestone for our PoC and its performance stood out from other commercial and open-source solutions.
Our second major milestone was to engineer more efficient data structures for the new store. To achieve this goal, we based our core hashtable structure on paper ["Dash: Scalable Hashing on Persistent Memory"](https://arxiv.org/abs/2003.07302). The paper itself is centered around persistent memory domain and is not directly related to main-memory stores.
Nevertheless, its contributions are very much applicable for our problem. It suggested a hashtable design that allowed us to maintain two special properties that are present in the Redis dictionary: a) its incremental hashing ability during datastore growth b) its ability to traverse the dictionary under changes using a stateless Scan operation. Besides these 2 properties,
Dashtable is much more efficient in CPU and memory. By leveraging DashTable's design, we were able to innovate further with the following features:
Our second challenge was to engineer more efficient data structures for the new store. To achieve this goal, we based our core hashtable structure on paper ["Dash: Scalable Hashing on Persistent Memory"](https://arxiv.org/pdf/2003.07302.pdf). The paper itself is centered around persistent memory domain and is not directly related to main-memory stores.
Nevertheless, its very much applicable for our problem. It suggested a hashtable design that allowed us to maintain two special properties that are present in the Redis dictionary: a) its incremental hashing ability during datastore growth b) its ability to traverse the dictionary under changes using a stateless scan operation. Besides these 2 properties,
Dash is much more efficient in CPU and memory. By leveraging Dash's design, we were able to innovate further with the following features:
* Efficient record expiry for TTL records.
* A novel cache eviction algorithm that achieves higher hit rates than other caching strategies like LRU and LFU with **zero memory overhead**.
* A novel **fork-less** snapshotting algorithm.
After we built the foundation for Dragonfly and [we were happy with its performance](#benchmarks),
we went on to implement the Redis and Memcached functionality. By now, we have implemented ~130 Redis commands (equivalent to 2.8 API) and 13 Memcached commands.
we went on to implement the Redis and Memcached functionality. By now, we have implemented ~130 Redis commands (equivalent to v2.8) and 13 Memcached commands.
And finally, <br>
<em>Our mission is to build a well-designed, ultra-fast, cost-efficient in-memory datastore for cloud workloads that take advantage of the latest hardware advancements. We intend to address the pain points of current solutions while preserving their product APIs and propositions.
<em>Our mission is to build a well-designed, ultra-fast, cost-efficient in-memory datastore for cloud workloads that takes advantage of the latest hardware advancements. We intend to address the pain points of current solutions while preserving their product APIs and propositions.
</em>
P.S. other engineers share a similar sentiment about what makes a good memory store. See, for example, [this](https://twitter.github.io/pelikan/2019/why-pelikan.html) and [this](https://twitter.github.io/pelikan/2021/segcache.html) blog posts from Twitter memcache team. Or [this post](https://medium.com/@john_63123/redis-should-be-multi-threaded-e28319cab744) from authors of keydb.
P.S. other engineers share a similar sentiment about what makes a good memory store. See, for example, [here](https://twitter.github.io/pelikan/2019/why-pelikan.html) and [here](https://twitter.github.io/pelikan/2021/segcache.html) blog posts from Twitter's memcache team, or [this post](https://medium.com/@john_63123/redis-should-be-multi-threaded-e28319cab744) from authors of keydb.
## Benchmarks
TODO.
## Running the server
@ -101,9 +103,6 @@ cd build-opt && ninja dragonfly # build
```
## Benchmarks
TODO.
## Roadmap and status
Currently Dragonfly supports ~130 Redis commands and all memcache commands besides `cas`.

View file

@ -112,7 +112,6 @@ the metadata. For small data use-cases the cost of metadata in Redis is larger t
### Multi-threaded scenario
Now I run Dragonfly on all 8 cores.
| | Dragonfly | Redis 6 |
|-------------|-----------|---------|
| Time | 2.43s | 16.0s |