1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00
Commit graph

2709 commits

Author SHA1 Message Date
Diskein
ba57145c53
fix!: fix BITPOS command responses (#3893) (#3910)
BITPOS returns 0 for non-existent keys according to Redis's
implmentation.

BITPOS allows only 0 and 1 as the bit mode argument.

Signed-off-by: Denis K <kalantaevskii@gmail.com>
2024-10-12 10:55:01 +03:00
Roman Gershman
5d2c308c99
chore: schedule chains (#3819)
Use intrusive queue that allows batching of scheduling calls instead of handling each call separately.
This optimizations improves latency and throughput by 3-5%
In addition, we expose batching statistics in info transaction block.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-10-11 22:41:31 +03:00
Vladislav
e71f083f34
feat(search): STOPWORDS (#3851)
Adds support for STOPWORDS option
2024-10-10 21:58:12 +03:00
adiholden
d876bcd5cb chore(helm-chart): update to v1.23.2 2024-10-10 18:22:34 +00:00
Kostas Kyrimis
0cea5fe2ff
chrore: parse cgroup v2 (#3857)
* chrore: parse cgroup v2

* small parsing logic
2024-10-10 19:15:26 +03:00
Andy Dunstall
1e429c8e59
fix(cluster): fix unknown migration error (#3899) 2024-10-10 10:14:15 +01:00
Kostas Kyrimis
a5fa3ab9f5
chore: skip flaky test_noreply_pipeline (#3903)
* Disable the test_noreply_pipeline because it's really flaky. Will look on this once I wrap up with my pending tasks.
2024-10-10 07:37:13 +00:00
Vladislav
786c9cd44d
chore: collection size (#3844) 2024-10-08 18:51:11 +03:00
Shahar Mike
50a7f2bcb1
fix: Do not kill Dragonfly on failed DFLY LOAD (#3892)
Today, some of the failures to load an RDB file passed via
`--dbfilename` cause Dragonfly to terminate with an error code. This is
ok and works as expected.

The problem is that the same code path is used for `DFLY LOAD`, which
means that if there's an error loading the file (such as corrupted
file), Dragonfly will exit instead of returning an error code to the
client.

This change fixes that, by only exiting in the code path which loads on
init.

Note to reviewer: apparently we can't call `Future::Get()` more than
once, as the first call resets the state of the future and drops the
previously saved value, so we use a Fiber here instead.
2024-10-08 14:47:31 +03:00
Shahar Mike
b2ebfd05d4
fix: Do not publish to connections without context (#3873)
* fix: Do not publish to connections without context

This is a rare case where a closed connection is kept alive while the
handling fiber yields, therefore leaving `cc_` (the connection context)
pointing to null for other fibers to see.

As far as I can see, this can only happen during server shutdown, but
there could be other cases that I have missed.

The test on its own does _not_ reproduce the crash, however with added
`ThisFiber::SleepFor()`s I could reproduce the crash:

* Right before `DispatchBrief()`
  [here](e3214cb603/src/server/channel_store.cc (L154))
* Right after connection context `reset()`
  [here](2ab480e160/src/facade/dragonfly_connection.cc (L750))

In any case, calling `SendPubMessageAsync()` to a connection where `cc_`
is null is a bug, and we fix that here.

* rewording
2024-10-08 14:45:57 +03:00
Kostas Kyrimis
c1e9d510a3
chore: lock keys for optimistic transactions (#3865)
We do not acquire any locks for transactions that are executing optimistically. However, this is problematic for callbacks that need to preempt (e.g. because a journal is active).

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-10-08 14:25:36 +03:00
Kostas Kyrimis
dac1b0f3ca
chore: allow rdb version 12 (#3860)
We currently support rdb files up to version 11. This is a blocker for people who want to migrate to dragonfly with newer versions of the format. As of now, there is only v12 and it only includes the addition of RDB_OPCODE_SLOT_INFO.

* adds support to load rdb files up to version 12
* reads and discards with a warning the contents of RDB_OPCODE_SLOT_INFO if found in the rdb file

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-10-07 07:14:11 +00:00
Shahar Mike
5efc8f11d2
opt: Optimize AllocationTracker to be efficient when enabled (#3875)
Today there's a cost to enabling AllocationTracker, even for rarely used
memory bands.

This PR slightly optimizes the "happy path" (i.e. allocations outside
the tracked range), and also for the case where we track 100% of the
allocations.

Also, add a unit test for this class.
2024-10-06 22:00:57 +03:00
Roman Gershman
45aba139b6
chore: reduce usage of ToUpper (#3874)
We would like to stop passing MutableSlice as arguments and removing ToUpper
is the first step to it.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-10-06 21:45:11 +03:00
Kostas Kyrimis
129ff0b0f7
chore: run memory decommit after snapshot load/save (#3828)
Sometimes for large values during snapshot loading/saving we allocate a lot of extra memory. For that, we might need to manually run memory decommit for mimalloc to release memory pages back to the OS. This PR addresses that by manually running memory decommit after each shard finishes loading or saving a snapshot.

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-10-06 08:19:24 +03:00
Roman Gershman
612c75c67b
chore: Refactor AddMany (#3869)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-10-05 19:27:48 +03:00
Andy Dunstall
4dbed3f8dd
feat(rdb_load): add support for loading huge streams (#3855)
* chore: remove RdbLoad Ltrace::arr nested vector

* feat(rdb_load): add support for loading huge streams
2024-10-05 07:19:03 +03:00
Roman Gershman
07e0b9db4b
chore: ClearInternal now can clear partially (#3867)
* chore: ClearInternal now can clear partially

Intended for future use - to deallocate large objects gradually.
Currently nothing is changed in the functionality besides some cleanups.
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-10-04 22:50:43 +03:00
Roman Gershman
bd972b6384
chore: Implement AddMany method (#3866)
* chore: Implement AddMany method

1. Fix a performance bug in Find2 that made redundant comparisons
2. Provide a method to StringSet that adds several items in a batch
3. Use AddMany inside set_family

Before:
```
BM_Add        4253939 ns      4253713 ns          991
```

After:
```
BM_Add        3482177 ns      3482050 ns         1206
BM_AddMany    3101622 ns      3101507 ns         1360
```

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

* chore: fixes

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-10-04 22:50:05 +03:00
Roman Gershman
a86fcf80be
chore: Remove DenseSet::AddOrFindDense and AddSds (#3864)
Clean up interface a bit. AddOrFindDense does not make much sense as a single function
because it does not provide any performance benefits - we still must perform a lookup
before inserting. AddSds should have been removed a long time ago.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-10-04 17:14:49 +03:00
Roman Gershman
2e1d81ac80
chore: improve performance of ClearInternal (#3863)
Before:
`BM_Clear/elements:32000     418763 ns       418749 ns         9965`

After:
`BM_Clear/elements:32000     323252 ns       323239 ns        12790`

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-10-04 14:26:25 +03:00
Joakim Rishaug
0f972a0ec6
feat: add HEXPIRE and FIELDEXPIRE (#3842)
* add hexpire
* add fieldexpire
* add tests
2024-10-04 14:24:16 +03:00
Roman Gershman
819f6e125d
chore: simplify CloneBatch code (#3862)
Remove awkward fetch_tail case and streamline the code.
Fix invalid prefetch adresses. Performance improved a little.

Before:
`BM_Fill/elements:32000     874677 ns       874647 ns         4774`

After:
`BM_Fill/elements:32000     831786 ns       831761 ns         5111`

Also added a benchmark for Clear() operation.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-10-04 12:08:41 +03:00
Daniel M
1958e09a9a
refactor: refactor fakeredis tests (#3852)
* refactor:fakeredis tests
2024-10-03 12:41:05 +03:00
Andy Dunstall
44fbe09108
fix(rdb_load): fix partial reads dropping elements (#3853) 2024-10-03 11:28:24 +03:00
Andy Dunstall
a066579930
feat(rdb_load): add support for loading huge lists (#3850)
* feat(rdb_load): add support for loading huge lists

* feat(rdb_load): add EnsureObjEncoding
2024-10-02 15:24:39 +03: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
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
Vladislav
beb2ec2b29
chore: WrapSds from family_utils.h (#3818)
* chore: WrapSds from family_utils.h
---------

Signed-off-by: Roman Gershman <romange@gmail.com>
Signed-off-by: Kostas Kyrimis  <kostaskyrim@gmail.com>
Co-authored-by: Roman Gershman <romange@gmail.com>
Co-authored-by: Kostas Kyrimis <kostaskyrim@gmail.com>
2024-10-01 15:29:22 +03:00
adiholden
fa288c19b2
test: more stabe test_bgsave_and_save (#3843)
Signed-off-by: adi_holden <adi@dragonflydb.io>
2024-10-01 15:03:12 +03:00
Joakim Rishaug
2ab480e160
add dense_set.SetExpiryTime in preparation for fieldexpire (#3780)
* feat: add DenseSet::IteratorBase::SetExpiryTime

This commit is in preparation for adding FIELDEXPIRE and HEXPIRE.

* fix: 0 is a valid input for MakeSetSds
2024-10-01 08:36:00 +00:00
Andy Dunstall
e3214cb603
feat(rdb_load): add support for loading huge hmaps and zsets (#3823)
* feat(rdb_load): add support for loading huge hmaps

* feat(rdb_load): add support for loading huge zsets

* feat(rdb_load): log DFATAL when append fails
2024-10-01 09:52:52 +03:00
Roman Gershman
2d11a046be
chore: add pending_ops to disk stats (#3837) 2024-10-01 09:51:53 +03:00
romange
79dc98dd03 chore(helm-chart): update to v1.23.1 2024-09-30 16:56:19 +00:00
Borys
843adf85a6
refactor: remove CmdArgParser::ToUpper() (#3831) 2024-09-30 14:17:44 +00:00
Roman Gershman
14c94e41d7
chore: optimize element removal for integer lists (#3827)
Fixes #3806

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-30 15:19:01 +03:00
Kostas Kyrimis
ec353e1522
chore: add logs to test_acl_cat_commands_multi_exec_squash (#3826)
* add logs to test

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-09-30 12:03:40 +00:00
Andy Dunstall
820431605e
fix(rdb_load): fix appending to an expired key (#3829) 2024-09-30 11:07:06 +00:00
Kostas Kyrimis
b19f722011
chore: do not close connections at the end of pytest (#3811)
A common case is that we need to clean up a connection before we exit a test via .close() method. This is needed because otherwise the connection will raise a warning that it is left unclosed. However, remembering to call .close() at each connection at the end of the test is cumbersome! Luckily, fixtures in python can be marked as async which allow us to:

* cache all clients created by DflyInstance.client()
* clean them all at the end of the fixture in one go

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-09-30 09:54:41 +03:00
Kostas Kyrimis
ed11c8d3a4
chore: allow config set notify_keyspace_events (#3790)
We do not allow notify_keyspace_events to be set at runtime via config set command.

* allow notify_keyspace_events in config set command
* add tests

---------

Signed-off-by: kostas <kostas@dragonflydb.io>
2024-09-30 09:54:02 +03:00
Andy Dunstall
5d64e1471a
fix(rdb_load): fix loading huge hmaps with ttl (#3825) 2024-09-30 08:34:28 +03:00
Roman Gershman
ee2f00de27
chore: now it's not needed to allocate quicklistIter on heap (#3814) 2024-09-29 12:46:57 +03:00
Andy Dunstall
520dea06bf
feat(rdb_load): add support for loading huge sets (#3807)
* feat(rdb_load): add support for loading huge sets
2024-09-29 10:25:30 +03:00
Roman Gershman
73002dc048
chore: add a benchmark comparing lpStringToInt64 to SimpleAtoi (#3815)
Seems that lpStringToInt64 is fairly optimized.
On c7g:

```
BM_LpString2Int/1      27383 ns        27381 ns       204149
BM_LpString2Int/2      24535 ns        24534 ns       227981
```

so SimpleAtoi has only ~10% improvement.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-29 09:04:25 +03:00
Roman Gershman
a3cabd10d3
chore: introduce an optimized integer compare algorithm for lists (#3813)
* chore: introduce an optimized integer compare algorithm for lists

Problem: when lists are long OpRem will spend lots of time comparing an element with records in the list.
For integer-based lists, most of the time is spent in lpCompare.
In addition, lpGet has lots of branches that penalize integers use-cases.

This PR:
1. Introduces lpGet2 - the improved version with less branches.
2. Benchmarks lpCompare vs an algorithm that compares records to an integer.
3. Benchmarks lpGet vs lpGet2

```
----------------------------------------------------------
Benchmark                Time             CPU   Iterations
----------------------------------------------------------
BM_LpCompare          1187 ns         1187 ns      4715144
BM_LpCompareInt        371 ns          371 ns     15216611
BM_LpGet/1             265 ns          265 ns     21473149
BM_LpGet/2             214 ns          214 ns     26075164
```

There are no functional changes to the Dragonfly code.

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

* chore: fixes

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-29 09:04:01 +03:00
Vladislav
753a7808d3
chore: singlehop XREAD (#3817)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-09-28 20:22:05 +03:00
Vladislav
55699a9bb9
chore: refactor XRead (#3775)
Previously XREAD:
- Fetched group consumer info (with a hop)
- Looked up last stream ids (with a hop)
- Determined if there are entries to read (on coordinator)
- Dispatched a hop to read entries or retired to blocking mode

Instead we can merge steps (1), (2) and (3) into a single step, optionally with step (4) for single shard operations that can avoid concluding (we had this optimization before)
2024-09-27 18:47:20 +00:00
Borys
895567f3b9
fix: empty strings and Nan in the sort command (#3809)
* fix: empty strings and Nan in the SORT command
2024-09-27 14:17:05 +03:00
Roman Gershman
8ae71411bd
chore: reformat listpack according to valkey 8 (#3810)
Also add benchmarks for lpCompare code when list contains integers.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-27 09:22:08 +00:00
Roman Gershman
6a13329523
fix: make sure dfly_bench reliably connects (#3802)
1. Issue ping upon connect, add a comment why.
2. log error if dfly_bench disconnects before all the requests were processed.
3. Refactor memcache parsing code into ParseMC function.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-09-26 23:28:20 +03:00