Commit graph

67 commits

Author SHA1 Message Date
Roman Gershman
6b4a5623e1
chore: supports reading huffman encoded strings from CompactObj
This requires implementing HashCode, operator== methods as well.
Fixes #4880

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2025-05-09 08:46:49 +03:00
Roman Gershman
9a05343b5f
feat: add huffman coding to compact object (#5080)
* feat: add huffman coding to compact object

Read path and tests will follow in the next PR.
Partially addresses #4880

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

* Update src/core/compact_object.cc

Co-authored-by: Kostas Kyrimis  <kostas@dragonflydb.io>
Signed-off-by: Roman Gershman <romange@gmail.com>

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Signed-off-by: Roman Gershman <romange@gmail.com>
Co-authored-by: Kostas Kyrimis <kostas@dragonflydb.io>
2025-05-08 10:21:20 +00:00
Roman Gershman
54328fd00e
chore: reorganize compact object mask bits (#5077)
Specifically get rit of MaskEnum and replace it with explicit bits aliasing the mask.
Reorganize the encoding bits to be able to store 4 states that include huffman encoding.

Solves the first part of #4880

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2025-05-07 15:08:22 +03:00
Roman Gershman
b3e0bcfb31
chore: further extend the compression analysis (#5065)
Allow export/import of huffman tables via
`DEBUG COMPRESSION EXPORT` or `DEBUG COMPRESSION IMPORT <bintable>`

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2025-05-06 13:15:54 +03:00
Abhijat Malviya
90e9ecb968
chore(zset_family/score_map): Replace sds arguments with string_view (#4738)
* chore(zset_family/score_map): Remove usages of sds

The usages of WrapSds are removed from zset_family calls.

Signed-off-by: Abhijat Malviya <abhijat@dragonflydb.io>
2025-03-27 17:41:11 +05:30
Roman Gershman
66c2973a99
fix: removal of Expiry bit when overriding external strings (#4785)
The bug: during the override of the existing external string, we called
`TieredStorage::Delete` to delete the external reference. This function
called CompactObj::Reset that cleared all the attributes on the value, including
expiry.

The fix: preserve the mask but clear the external state from the object.
Fixes #4672

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2025-03-17 13:45:07 +02:00
Roman Gershman
4fe6dabd3c
fix: pull latest helio (#4651)
Latest helio fixes the bug in DnsResolve - fixes #4244

Also, add some comments and perform minor clean ups in tiered codebase.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2025-02-24 17:00:54 +02:00
adiholden
6016ae1ec8
feat(server): rdb loader big string loading in chunks (#4623)
1. rdb loader big string loading in chunks 
2. snapshot compression logic is disabled in case of big buffer

Signed-off-by: adi_holden <adi@dragonflydb.io>
2025-02-20 16:56:15 +02:00
Roman Gershman
fcf5ff6af8
chore: introduce background deletions of DenseSet objects (#4496)
* chore: introduce background deletions of DenseSet objects

We currently implement them only for sets but the same approach can work for zset, hashes, lists as well.
2025-02-19 13:21:22 +02:00
Kostas Kyrimis
66e0fd0908
fix: stream memory tracking (#4067)
* add object memory usage for streams
* add test
2024-11-27 12:41:08 +02:00
Roman Gershman
581cfbf6c5
chore: allow slow and precise memory measurement of an object (#4160)
Specifically fixes "MEMORY USAGE" for lists.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-11-21 09:21:48 +02:00
Roman Gershman
75c961e7ed
chore: Add initial bindings for QList in list_family (#4093)
The feature is guarded by list_experimental_v2 flag, which is disabled.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-11-10 07:40:50 +02:00
Roman Gershman
a01dfcb5b6
chore: extend RobjWrapper::sz_ to 2^56 (#3849)
Also remove unused quicklist function.
Relates to #3800

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-10-02 11:20:34 +03:00
Kostas Kyrimis
6e45c9c3e2
fix: properly track json memory usage (#3641)
* add JsonMemTracker
* add logic based on MiMallocResource deltas that calculates json object usage
* add test

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-09-18 13:08:43 +00:00
Kostas Kyrimis
b979994025
fix: skip empty objects on load and replication (#3514)
* skip empty objects in rdb save
* skip empty objects in rdb load
* delete empty keys in FindReadOnly

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-08-20 09:44:41 +03:00
Vladislav
1a8c12225b
chore(tiering): Move cool entry warmup to DbSlice (#3397)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-07-28 17:30:41 +03:00
Stepan Bagritsevich
28cfde0a27
fix: Fix unsupported object type rejson-rl in RedisInsight (#3384)
* fix: Fix unsupported object type rejson-rl in RedisInsight

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

* fix(generic_family): fix case for the TYPE option in SCAN command

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

* feat(generic_family_test): Add test for the Redis GUI

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

* refactor: address comments

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

* refactor: address comments 2

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

* refactor: change variable name from obj_type_as_string to obj_type

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>

---------

Signed-off-by: Stepan Bagritsevich <bagr.stepan@gmail.com>
2024-07-27 19:05:00 +02:00
Roman Gershman
0a26a06065
chore: tiered fixes (#3393)
1. Use introsive::list for CoolQueue.
2. Make sure that we ignore cool memory usage when computing average object size to
   prevent evictions during dashtable growth attempts.
3. Remove items from the cool storage before evicting them from the dash table.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-25 23:38:44 +03:00
Roman Gershman
e2d65a0900
chore: reenable evictions upon insertion to avoid OOM rejections (#3387)
* chore: reenable evictions upon insertion to avoid OOM rejections

Before: when running dragonfly with --cache_mode we could get OOM rejections
even though the eviction policy allowed to evict items to free memory.
Ideally, dragonfly in cache mode should not respond with the OOM error.

This PR reuses the same Eviction step we have in the Heartbeat and conditionally applies it
during the insertion. In my test the OOM errors went from 500K to 0 and the server
still respected memory limit.

Also, remove the old heuristics that has never been used.

Test:

./dfly_bench --key_prefix=bar: -d 1024 --ratio=1:0 --qps=200 -n 3000
./dragonfly --dbfilename=  --proactor_threads=2 --maxmemory=600M --cache_mode

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-25 15:28:57 +03:00
Roman Gershman
c8a98fd110
chore: small fixes around tiering (#3368)
There are no changes in functionality here.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-23 16:00:50 +03:00
Roman Gershman
cd1f9d3923
chore: Introduce CoolQueue (#3365)
Also, add the according API to compact object.
Now external objects can be in two states: Cool and Offloaded.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-23 12:41:10 +03:00
Roman Gershman
b9f8671df9
chore(tiering): add protection against overruning memory budget (#3327)
chore(tiering): Introduce second chance replacement strategy

Introduce hot/cold replacement strategy https://www.geeksforgeeks.org/second-chance-or-clock-page-replacement-policy/

Also, add protection against overruning memory budget
Finally, cancel in-flight offloading requests for entries that were looked up.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-18 03:52:43 -04:00
Roman Gershman
35ef143200
chore: bypass decoding/encoding of the data when performing offloading (#3315)
It's more efficient to offload raw blobs kept in CompactObject than decoded strings.
Unfortunately, it's also more complicated. The complexity arises around Read/Modify operations
that must convert a raw blob into a processed string. Moreover, Modify decodes the raw string, therefore
subsequent callbacks already see the decoded string.

Finally, this PR fixes the logic in NotifyFetched flow:
before it could skip uploading the modified value back to memory, which breaks correctness.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-07-15 13:16:43 +03:00
Roman Gershman
bdf417cb2f
chore: Add CompactObj Raw methods (#3303)
* chore: Add CompactObj Raw methods

Currently, compact object does decoding/encoding of its internal string blobs.
For tiering usecase, it makes sense to introduce the direct access to the blobs and avoid
this unnecessary translation.

This PR introduces such access.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Signed-off-by: Roman Gershman <romange@gmail.com>
Co-authored-by: Shahar Mike <chakaz@users.noreply.github.com>
2024-07-10 20:59:37 +03:00
Roman Gershman
038d081fd0
chore: refactor compact_object and introduce materialize method (#3300) 2024-07-10 13:57:59 +03:00
Vladislav
f27506e678
feat(tiering): simple offload loop (#2987)
Simple offloading for tiering

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-05-06 22:28:45 +03:00
Kostas Kyrimis
0d91e0313d
chore: generalize CompactObject::AllocateMR (#2847)
* allow AllocateMR from args
2024-04-05 13:55:37 +03:00
Roman Gershman
1987d1af70
chore: expose direct API on Bloom objects (#2845)
Needed to be able to (de)serialize SBF objects.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-04-05 11:38:09 +03:00
Roman Gershman
c8426cfd31
chore: implement path mutation for JsonFlat (#2805)
* chore: implement path mutation for JsonFlat

This is done by converting the flat blob into mutable c++ json
and then building a new flat blob.

Also, add JsonFlat encoding to CompactObject class.
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-04-04 17:33:56 +00:00
Kostas Kyrimis
44b0283122
fix: SBF memory leaks (#2803)
* fix: sbl memory leaks
2024-03-31 17:51:14 +03:00
Roman Gershman
7f0f624699
feat: add bf.(m)add and bf.(m)exists commands (#2801)
Adresses #1275

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-03-31 15:50:21 +03:00
Roman Gershman
9e23f85e6b
chore: expose SBF via compact_object (#2797)
* chore: expose SBF via compact_object
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-03-30 22:35:22 +03:00
Roman Gershman
fa75360227
chore: get rid of object.c and robj* in cc code (#2610)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-02-18 16:52:23 +02:00
Roman Gershman
d802a2181a
chore: consolidate json code under core/json (#2609)
Fix linker dependencies - now dfly_core depends on jsonpath.
jsonpath does not depend on CompactObject anymore.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-02-18 09:22:34 +00:00
Roman Gershman
1ba59e9179
chore: remove ImportRObj routine and reduce reliance on object.c (#2607)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-02-18 10:07:00 +02:00
adiholden
32e8d49123
feat(tiering): add background offload step (#2504)
* feat(tiering): add background offload step

Signed-off-by: adi_holden <adi@dragonflydb.io
2024-02-14 14:28:41 +02:00
adiholden
9f3b118b87
server(tiering): load data on read (#2415)
* server(tiering): load data on read

Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-01-17 16:13:56 +02:00
adiholden
014a86fc88
feat(lru): add generic lru class (#2351)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-01-07 21:51:46 +02:00
Shahar Mike
34986fc52e
feat(server): Account for RObj concrete objects (#2324)
* feat(server): Account for RObj concrete objects

* proper `delete`
2023-12-22 09:20:41 +02:00
Shahar Mike
636507c356
feat(server): Return per-type memory breakdown from INFO and /metrics (#2262)
* feat(server): Return per-type memory breakdown from INFO and /metrics

* OBJ_TYPE_MAX

* Move AddTypeMemoryUsage, use it from TieredStorage

* Remove strval_memory_usage

* Remove redundant strval_bytes

---------

Signed-off-by: Shahar Mike <chakaz@users.noreply.github.com>
2023-12-07 21:37:09 +02:00
Vladislav
75fdc16f13
fix: fix defrag stats (#1740)
* fix: fix defrag stats

Signed-off-by: Vladislav <vladislav.oleshko@gmail.com>
2023-08-27 11:26:28 +03:00
Roman Gershman
464fa30272
chore: Refactor SortedMap (#1666)
* chore: Refactor SortedMap

1. intoduce variant of Redis and Dragonfly implementation and
wrap each operation with a dedicated dispatcher operator.
The dragonfly implementation path is a noop and not implemented.

2. Introduce a very basic sorted_map_test around Add and move the unrelated old test
   from sorted_map_test to bptree_set_test.
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-08-09 11:16:58 +03:00
Kostas Kyrimis
078d152ae0
feat: add replication over tls (#1525)
1. Introduces `tls_replication` flag to allow tls connections for replicas
2. Add pytests
2023-07-19 18:21:46 +00:00
Roman Gershman
e5be30cc79
chore: introduce sorted_map (#1558)
Consolidate skiplist based zset functionality into a dedicated class
called SortedMap. The code is adapted from t_zset.c
The old code in t_zset.c is deleted.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-07-18 09:56:45 +03:00
Roman Gershman
2c04311cc3
chore: Remove robj reference from zset_family (#1554)
This is pure refactoring PR that does not change any functionality besides
prohibiting using AsRobj/SyncRobj functions for compact objects of type
OBJ_ZSET. This is needed in case we decide in the future to implement our own
zset type.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-07-17 09:34:12 +03:00
Roman Gershman
cf1ac87156
chore: fix some of FreeBsd compile issues. (#1374)
1. Use experimental/memory_resource because clang on freebsd does not support yet std::memory_resource
2. Pull latest helio with all the compatibility fixes.
3. Replace linux only SOL_TCP constant with IPPROTO_TCP (same value).
4. Fix build files to work on FreeBsd system.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-06-11 23:22:56 +03:00
Roy Jacobson
ad7b4cf368
chore: Add clang workflow to CI (#1220)
* chore: Add clang workflow to CI

* Small fixes/warnings

* Disable Werror for clang
2023-05-23 14:22:28 +03:00
Roman Gershman
63b83c5b99
chore: Add tiered_storage_test. (#613)
1. Support tiered deletion.
2. Add notion of tiered entity in "DEBUG OBJECT" output.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-12-28 10:37:55 +02:00
Roman Gershman
adb3266825
feat(server): Redesign and simplify tiered storage module. (#589)
1. Allow offloading blobs larger than 2KB.
2. Totally redesign the offloading algorithm for blobs smaller than 2KB.
3. Fix bugs around IO request cancelations.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-12-22 03:58:58 +02:00
Roman Gershman
bcafd7e25d
feat: introduce simd algorithm for bitpacking (#568)
My benchmark shows a x3.5 improvement when compressing a 1KB string.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2022-12-17 19:22:40 +02:00