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>
The interface around DenseLinkKey is confusing but SetObject
works only for non-link objects.
Added assert to catch these issues in the future.
Fixes#3973
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
* 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>
* 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>
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>
* feat: add DenseSet::IteratorBase::SetExpiryTime
This commit is in preparation for adding FIELDEXPIRE and HEXPIRE.
* fix: 0 is a valid input for MakeSetSds
* chore: introduce a Clone function for the dense set
We use a state machine to prefetch data in batches.
After this change, the hot spots are predominantly inside ObjectClone and
Hash methods.
All in all benchmarks show ~45% CPU reduction:
```
BM_Clone/elements:32000 1517322 ns 1517338 ns 2772
BM_Fill/elements:32000 841087 ns 841097 ns 4900
```
---------
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
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.
1. ExpireIfNeeded was unjuistifiedly high in the profile topk table.
Lets make the initial condition within an inline to reduce its impact.
2. Reserve space for hmap/zset if multiple items are added.
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
A regular DenseSet insertion first checks for uniqueness and then inserts a new element.
Sometimes we know that the new element is new and we can insert it without checking for
uniqueness first.
Also, pass hashcode into internal functions so we could save some hash calls.
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
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>
Now string_map respects the optional ttl argument that accepts ttl time in seconds.
Upon traversing and accessing expirerd elements they will be transparently removed and deleted
from the map.
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Add SADDEX <key> <seconds> member member ....
Provides expiry semantics for set members with seconds resolution.
Important things to note:
1. The expiry is passive only, so if nobody touches that set then its members are being kept.
2. SCARD provides an upper bound estimation of set size for sets holding the expiring members.
The reason for this is because SCARD returns a cached size and does not go over all members
to check whether they expired. For regular sets it's exact, of course.
Fixes#335
* feat(core): Added DenseSet & StringSet types with docs
- Improved documentation by adding labels to chain types & pointer tagging table
- Added potential improvements to the DenseSet types in the docs
- Added excalidraw save file for future editing
- Removed ambiguous overloading types
- Renamed iterators to be more clear
* feat(core): Cleaned up DenseSet and Docs
* feat(core): Made DenseSet more ergonomic
* feat(server): Integration of DenseSet into Server
- Integrated DenseSet with CompactObj and the Set Family commands
Signed-off-by: Braydn <braydn.moore@uwaterloo.ca>