Commit graph

102 commits

Author SHA1 Message Date
Roman Gershman
b8ef7cdf69
chore: allow setting huffman tables via DEBUG COMPRESSION SET (#5083)
Also, revert the impact of performance bomb from #2564

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2025-05-08 22:10:59 +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
1e40e3aa9b
fix: remove code duplicate in GetSlice (#5079)
* fix: remove code duplicate in GetSlice

* Update src/core/compact_object.cc

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

* Update src/core/compact_object.cc

Signed-off-by: Kostas Kyrimis  <kostaskyrim@gmail.com>

---------

Signed-off-by: Roman Gershman <romange@gmail.com>
Signed-off-by: Kostas Kyrimis  <kostaskyrim@gmail.com>
Co-authored-by: Kostas Kyrimis <kostas@dragonflydb.io>
2025-05-07 19:14:16 +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
Stepan Bagritsevich
39a00806c9
fix(stream_family): Fix memory tracking for the STREAMs. SECOND PR (#4781)
* fix(stream_family): Fix memory tracking for the STREAMs

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* refactor: address comments

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

---------

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2025-04-14 13:07:17 +02:00
Stepan Bagritsevich
f4f615ff34
fix(rdb_load): Handle JSON loading failure when parsing fails (#4801)
* fix(rdb_load): Handle JSON loading failure when parsing fails

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* refactor(compact_obj): Clean up code

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* refactor: address comments

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

---------

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2025-03-28 14:30:10 +01: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
Stepan Bagritsevich
ca65a49a0f
fix(json_family): Fix memory tracking for JSON (#4777)
* fix(json_family): Fix memory tracking for JSON

fixes dragonflydb#4725

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* refactor: address comments

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* small fix

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

---------

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
2025-03-20 10:23:58 +01:00
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
54b864b2c7
chore: get rid of sds in SortedMap::AddElem (#4638)
chore: get rid of sds in SortedMap functions

Switch them to string_view interfaces.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2025-02-21 11:07:53 +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
Kostas Kyrimis
fbd785cbc7
chore: add defrag for StringSet (#4308)
* add defrag logic for StringSet
* add test
2025-01-27 12:53:38 +02:00
Roman Gershman
f3426bd559
chore: update jsoncons version to 0.178 (#4368)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2025-01-08 20:05:50 +02:00
Roman Gershman
7a68528022
chore: minor refactorings around dense_set deletions (#4390)
chore: refactorings around deletions

Done as a preparation to introduce asynchronous deletions for sets/zsets/hmaps.
1. Restrict the interface around DbSlice::Del. Now it requires for the iterator to be valid and the checks should
be explicit before the call. Most callers already provides a valid iterator.

2. Some minor refactoring in compact_object_test.
3. Expose DenseSet::ClearStep to allow iterative deletions of elements.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2025-01-02 11:35:55 +02:00
Roman Gershman
01f24da2b6
fix: configure jsonconst double parser to use std::from_chars (#4360)
The problem: apparently, jsoncons uses strtod by default when parsing doubles.
On some platforms (alpine/musl) this function uses lots of stack, which potentially can lead to stack corruption.
This PR configures jsoncons to use std::from_chars that is more efficient and less stack hungry.
The single include point to consume jsoncons/json.hpp should be "core/json_object.h"

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-12-24 04:02:50 +02:00
Shahar Mike
0562796cac
fix: Do not attempt to defrag StringSet as a StringMap (#4283)
That'd be a total waste of time and energy, not to mention you'll crash.

Fixes #4167
2024-12-10 08:44:52 +00:00
Roman Gershman
8d343bfd69
fix: stream bugs (#4240)
This PR syncs some of the improvements that were introduced in streams in Redis 7.2.3 OSS.

1. verify xsetid against max deleted id in the stream
2. Implement precise memory measurement of streams for "memory usage" command.
3. Always compact nodes in stream listpacks after creating new nodes.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-12-03 16:12:54 +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
Kostas Kyrimis
c5a8008348
chore: add defrag logic for zsets (#3836)
* add defrag logic for zsets
* add tests

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-10-23 10:56:56 +03:00
Kostas Kyrimis
a3abf41f4e
chore: add defrag logic for sets (#3833)
* add defrag logic for sets
* add small test


---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-10-02 10:00:15 +03:00
Kostas Kyrimis
0e0b2e78a4
chore: change log level to warning for empty keys (#3722)
* adjust log level to warning for allowed empty keys in rdb_load and rdb_save

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-09-19 09:45:09 +00: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
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
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
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
adiholden
a95419b0c4
fix(server): small string allocations only under 256 bytes str (#2991)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-05-02 10:32:05 +00:00
Roman Gershman
57d567639c
chore: serialize SBF (#2846)
* chore: serialize SBF

SAVE/LOAD supports SBF now. Also fixes MallocUsed for SBF.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-04-09 09:57:24 +03:00
Kostas Kyrimis
0d91e0313d
chore: generalize CompactObject::AllocateMR (#2847)
* allow AllocateMR from args
2024-04-05 13:55:37 +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
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
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
Roman Gershman
6aafe3dc5e
chore: cleanup of redis implementation of sets/hashmaps (#2605)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-02-17 18:35:28 +02:00
Kostas Kyrimis
795d00021d
fix: asan errors on unit tests (#2564)
* fix: asan errors on unit tests
2024-02-10 19:48:00 +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
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
Shahar Mike
7e23c14c35
fix(DenseSet): Rename Size() to UpperBoundSize() and add SizeSlow() (#2130)
Then use the right version (hopefully) in the right places.

Specifically, this fixes a serialization bug, where we could send
malformed responses when using `UpperBoundSize()` to write array length.
2023-11-06 08:52:08 +02:00
Roman Gershman
b67e4d8bb6
chore: improve doubles encoding for listpacks (#1938)
chore: reduce double encoding for listpacks

Following memory improvements by Redis 7, use double convrsion library to represent
double values with less space for listpacks.

The change is to use double conversion library instead of plain sprintf inside
zzlInsertAt. This requires to move zzlInsertAt to Dragonfly codebase.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-09-26 22:24:37 +03:00
Roman Gershman
8d1474aeac
fix: improve performance of listpack sorted sets (#1885)
1. Cherry-pick changes from Redis 7 that encode integer scores more efficiently
2. Introduces optimization that first checks if the new element should be the last
   for listpack sorted sets.
3. Consolidates listpack related constants and tightens usage for listpack.
4. Introduce MEMORY USAGE command.
5. Introduce a small delay before decommitting memory pages back to OS.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2023-09-19 19:52:34 +03: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
Vladislav
731f36edd2
feat: Defragmentation for hash values (#1727)
* feat: defrag hash

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>

* fix: change tests to real scenarios

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>

* fix: handle link nodes

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-08-24 18:17:28 +03:00