Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
de77fbb
introduce volatile_set implementation
ranshid Jun 26, 2025
6be1bd0
fix comparison
ranshid Jun 26, 2025
6df722f
fix typos
ranshid Jun 26, 2025
52d8a25
fix 32bit compilation and forgoten test file
ranshid Jun 26, 2025
344d487
add volatile set test condition
ranshid Jun 27, 2025
9d900dc
fix a bug in handling a removal from vecotr of size 1
ranshid Jun 27, 2025
603bbe1
fix pop expired
ranshid Jun 27, 2025
680a36a
change volatile_set to vset
ranshid Jun 28, 2025
e1ace27
1. change to vset
ranshid Jun 29, 2025
1f03adc
fix vset unittest name run
ranshid Jun 29, 2025
05a731c
replace vset "virtual table" with explicit function parameters to get…
ranshid Jun 29, 2025
d464f4f
explicit include stdlib for abs
ranshid Jun 29, 2025
69491e4
make vset a simple bucket pointer
ranshid Jun 29, 2025
2cdca33
fix some format issues
ranshid Jun 29, 2025
7d55e79
address PR comments
ranshid Jun 30, 2025
54e52bf
More fixes following the pr review:
ranshid Jun 30, 2025
46eacf6
fix vset comment arrow use in documentation
ranshid Jun 30, 2025
688f208
add public API documentation
ranshid Jun 30, 2025
597f0d4
polish comments and documentation
ranshid Jun 30, 2025
9c260e3
change sv to pv in multiple places
ranshid Jun 30, 2025
c4dd877
Use unsorted vector for most caeses.
ranshid Jun 30, 2025
b01ec8d
fix compilation warning
ranshid Jun 30, 2025
b11b143
Introduce a multi pop method for expiration entries
ranshid Jul 1, 2025
5058953
fix format and spelcheck
ranshid Jul 1, 2025
0c3fb77
revert changes to object.c (they belong in a separate PR)
ranshid Jul 1, 2025
f8e5bc1
fix new function names and documentation
ranshid Jul 1, 2025
3e55e3f
Merge remote-tracking branch 'valkey-fork/ttl-poc-new' into introduce…
ranshid Jul 1, 2025
fa8a499
fix memory leak in t_hash.
ranshid Jul 1, 2025
af1c360
format fix
ranshid Jul 1, 2025
9734290
add vset memory usage
ranshid Jul 1, 2025
f66e785
Merge remote-tracking branch 'valkey-fork/ttl-poc-new' into introduce…
ranshid Jul 1, 2025
17bea7f
Merge remote-tracking branch 'valkey-fork/ttl-poc-new' into introduce…
ranshid Jul 2, 2025
8d1cbeb
Merge remote-tracking branch 'valkey-fork/ttl-poc-new' into introduce…
ranshid Jul 3, 2025
6c7e841
optimize vsetUpdateEntry to avoid unnecessary mutations
ranshid Jul 3, 2025
01eed46
handle case of unsorted vector after update
ranshid Jul 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/t_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void hashTypeUntrackEntry(robj *o, void *entry) {
volatile_set *set = hashTypeGetVolatileSet(o);
debugServerAssert(set);
serverAssert(volatileSetRemoveEntry(set, entry, entryGetExpiry(entry)));
if (volatileSetNumEntries(set) == 0) {
if (volatileSetIsEmpty(set)) {
hashTypeDeleteVolatileSet(o);
}
}
Expand All @@ -132,7 +132,7 @@ static void hashTypeTrackUpdateEntry(robj *o, void *old_entry, void *new_entry,
debugServerAssert(set);
serverAssert(volatileSetUpdateEntry(set, old_entry, new_entry, old_expiry, new_expiry) == 1);
}
if (volatileSetNumEntries(set) == 0) {
if (volatileSetIsEmpty(set)) {
hashTypeDeleteVolatileSet(o);
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/unit/test_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ int test_dictDisableResizeReduceTo3(int argc, char **argv, int flags);
int test_dictDeleteOneKeyTriggerResizeAgain(int argc, char **argv, int flags);
int test_dictBenchmark(int argc, char **argv, int flags);
int test_endianconv(int argc, char *argv[], int flags);
int test_entryCreate(int argc, char **argv, int flags);
int test_entryUpdate(int argc, char **argv, int flags);
int test_entryHasexpiry_entrySetExpiry(int argc, char **argv, int flags);
int test_entryIsExpired(int argc, char **argv, int flags);
int test_entryMemUsage_entrySetExpiry_entrySetValue(int argc, char **argv, int flags);
int test_cursor(int argc, char **argv, int flags);
int test_set_hash_function_seed(int argc, char **argv, int flags);
int test_add_find_delete(int argc, char **argv, int flags);
Expand Down Expand Up @@ -201,6 +196,11 @@ int test_version2num(int argc, char **argv, int flags);
int test_reclaimFilePageCache(int argc, char **argv, int flags);
int test_valkey_strtod(int argc, char **argv, int flags);
int test_vector(int argc, char **argv, int flags);
int test_volatile_set_add_and_iterate(int argc, char **argv, int flags);
int test_volatile_set_large_batch_same_expiry(int argc, char **argv, int flags);
int test_volatile_set_iterate_multiple_expiries(int argc, char **argv, int flags);
int test_volatile_set_add_and_remove_all(int argc, char **argv, int flags);
int test_volatile_set_fuzzer(int argc, char **argv, int flags);
int test_ziplistCreateIntList(int argc, char **argv, int flags);
int test_ziplistPop(int argc, char **argv, int flags);
int test_ziplistGetElementAtIndex3(int argc, char **argv, int flags);
Expand Down Expand Up @@ -248,7 +248,6 @@ unitTest __test_crc64_c[] = {{"test_crc64", test_crc64}, {NULL, NULL}};
unitTest __test_crc64combine_c[] = {{"test_crc64combine", test_crc64combine}, {NULL, NULL}};
unitTest __test_dict_c[] = {{"test_dictCreate", test_dictCreate}, {"test_dictAdd16Keys", test_dictAdd16Keys}, {"test_dictDisableResize", test_dictDisableResize}, {"test_dictAddOneKeyTriggerResize", test_dictAddOneKeyTriggerResize}, {"test_dictDeleteKeys", test_dictDeleteKeys}, {"test_dictDeleteOneKeyTriggerResize", test_dictDeleteOneKeyTriggerResize}, {"test_dictEmptyDirAdd128Keys", test_dictEmptyDirAdd128Keys}, {"test_dictDisableResizeReduceTo3", test_dictDisableResizeReduceTo3}, {"test_dictDeleteOneKeyTriggerResizeAgain", test_dictDeleteOneKeyTriggerResizeAgain}, {"test_dictBenchmark", test_dictBenchmark}, {NULL, NULL}};
unitTest __test_endianconv_c[] = {{"test_endianconv", test_endianconv}, {NULL, NULL}};
unitTest __test_entry_c[] = {{"test_entryCreate", test_entryCreate}, {"test_entryUpdate", test_entryUpdate}, {"test_entryHasexpiry_entrySetExpiry", test_entryHasexpiry_entrySetExpiry}, {"test_entryIsExpired", test_entryIsExpired}, {"test_entryMemUsage_entrySetExpiry_entrySetValue", test_entryMemUsage_entrySetExpiry_entrySetValue}, {NULL, NULL}};
unitTest __test_hashtable_c[] = {{"test_cursor", test_cursor}, {"test_set_hash_function_seed", test_set_hash_function_seed}, {"test_add_find_delete", test_add_find_delete}, {"test_add_find_delete_avoid_resize", test_add_find_delete_avoid_resize}, {"test_instant_rehashing", test_instant_rehashing}, {"test_bucket_chain_length", test_bucket_chain_length}, {"test_two_phase_insert_and_pop", test_two_phase_insert_and_pop}, {"test_replace_reallocated_entry", test_replace_reallocated_entry}, {"test_incremental_find", test_incremental_find}, {"test_scan", test_scan}, {"test_iterator", test_iterator}, {"test_safe_iterator", test_safe_iterator}, {"test_compact_bucket_chain", test_compact_bucket_chain}, {"test_random_entry", test_random_entry}, {"test_random_entry_with_long_chain", test_random_entry_with_long_chain}, {"test_random_entry_sparse_table", test_random_entry_sparse_table}, {"test_all_memory_freed", test_all_memory_freed}, {NULL, NULL}};
unitTest __test_intset_c[] = {{"test_intsetValueEncodings", test_intsetValueEncodings}, {"test_intsetBasicAdding", test_intsetBasicAdding}, {"test_intsetLargeNumberRandomAdd", test_intsetLargeNumberRandomAdd}, {"test_intsetUpgradeFromint16Toint32", test_intsetUpgradeFromint16Toint32}, {"test_intsetUpgradeFromint16Toint64", test_intsetUpgradeFromint16Toint64}, {"test_intsetUpgradeFromint32Toint64", test_intsetUpgradeFromint32Toint64}, {"test_intsetStressLookups", test_intsetStressLookups}, {"test_intsetStressAddDelete", test_intsetStressAddDelete}, {NULL, NULL}};
unitTest __test_kvstore_c[] = {{"test_kvstoreAdd16Keys", test_kvstoreAdd16Keys}, {"test_kvstoreIteratorRemoveAllKeysNoDeleteEmptyHashtable", test_kvstoreIteratorRemoveAllKeysNoDeleteEmptyHashtable}, {"test_kvstoreIteratorRemoveAllKeysDeleteEmptyHashtable", test_kvstoreIteratorRemoveAllKeysDeleteEmptyHashtable}, {"test_kvstoreHashtableIteratorRemoveAllKeysNoDeleteEmptyHashtable", test_kvstoreHashtableIteratorRemoveAllKeysNoDeleteEmptyHashtable}, {"test_kvstoreHashtableIteratorRemoveAllKeysDeleteEmptyHashtable", test_kvstoreHashtableIteratorRemoveAllKeysDeleteEmptyHashtable}, {NULL, NULL}};
Expand All @@ -262,6 +261,7 @@ unitTest __test_sha1_c[] = {{"test_sha1", test_sha1}, {NULL, NULL}};
unitTest __test_util_c[] = {{"test_string2ll", test_string2ll}, {"test_string2l", test_string2l}, {"test_ll2string", test_ll2string}, {"test_ld2string", test_ld2string}, {"test_fixedpoint_d2string", test_fixedpoint_d2string}, {"test_version2num", test_version2num}, {"test_reclaimFilePageCache", test_reclaimFilePageCache}, {NULL, NULL}};
unitTest __test_valkey_strtod_c[] = {{"test_valkey_strtod", test_valkey_strtod}, {NULL, NULL}};
unitTest __test_vector_c[] = {{"test_vector", test_vector}, {NULL, NULL}};
unitTest __test_volatile_set_c[] = {{"test_volatile_set_add_and_iterate", test_volatile_set_add_and_iterate}, {"test_volatile_set_large_batch_same_expiry", test_volatile_set_large_batch_same_expiry}, {"test_volatile_set_iterate_multiple_expiries", test_volatile_set_iterate_multiple_expiries}, {"test_volatile_set_add_and_remove_all", test_volatile_set_add_and_remove_all}, {"test_volatile_set_fuzzer", test_volatile_set_fuzzer}, {NULL, NULL}};
unitTest __test_ziplist_c[] = {{"test_ziplistCreateIntList", test_ziplistCreateIntList}, {"test_ziplistPop", test_ziplistPop}, {"test_ziplistGetElementAtIndex3", test_ziplistGetElementAtIndex3}, {"test_ziplistGetElementOutOfRange", test_ziplistGetElementOutOfRange}, {"test_ziplistGetLastElement", test_ziplistGetLastElement}, {"test_ziplistGetFirstElement", test_ziplistGetFirstElement}, {"test_ziplistGetElementOutOfRangeReverse", test_ziplistGetElementOutOfRangeReverse}, {"test_ziplistIterateThroughFullList", test_ziplistIterateThroughFullList}, {"test_ziplistIterateThroughListFrom1ToEnd", test_ziplistIterateThroughListFrom1ToEnd}, {"test_ziplistIterateThroughListFrom2ToEnd", test_ziplistIterateThroughListFrom2ToEnd}, {"test_ziplistIterateThroughStartOutOfRange", test_ziplistIterateThroughStartOutOfRange}, {"test_ziplistIterateBackToFront", test_ziplistIterateBackToFront}, {"test_ziplistIterateBackToFrontDeletingAllItems", test_ziplistIterateBackToFrontDeletingAllItems}, {"test_ziplistDeleteInclusiveRange0To0", test_ziplistDeleteInclusiveRange0To0}, {"test_ziplistDeleteInclusiveRange0To1", test_ziplistDeleteInclusiveRange0To1}, {"test_ziplistDeleteInclusiveRange1To2", test_ziplistDeleteInclusiveRange1To2}, {"test_ziplistDeleteWithStartIndexOutOfRange", test_ziplistDeleteWithStartIndexOutOfRange}, {"test_ziplistDeleteWithNumOverflow", test_ziplistDeleteWithNumOverflow}, {"test_ziplistDeleteFooWhileIterating", test_ziplistDeleteFooWhileIterating}, {"test_ziplistReplaceWithSameSize", test_ziplistReplaceWithSameSize}, {"test_ziplistReplaceWithDifferentSize", test_ziplistReplaceWithDifferentSize}, {"test_ziplistRegressionTestForOver255ByteStrings", test_ziplistRegressionTestForOver255ByteStrings}, {"test_ziplistRegressionTestDeleteNextToLastEntries", test_ziplistRegressionTestDeleteNextToLastEntries}, {"test_ziplistCreateLongListAndCheckIndices", test_ziplistCreateLongListAndCheckIndices}, {"test_ziplistCompareStringWithZiplistEntries", test_ziplistCompareStringWithZiplistEntries}, {"test_ziplistMergeTest", test_ziplistMergeTest}, {"test_ziplistStressWithRandomPayloadsOfDifferentEncoding", test_ziplistStressWithRandomPayloadsOfDifferentEncoding}, {"test_ziplistCascadeUpdateEdgeCases", test_ziplistCascadeUpdateEdgeCases}, {"test_ziplistInsertEdgeCase", test_ziplistInsertEdgeCase}, {"test_ziplistStressWithVariableSize", test_ziplistStressWithVariableSize}, {"test_BenchmarkziplistFind", test_BenchmarkziplistFind}, {"test_BenchmarkziplistIndex", test_BenchmarkziplistIndex}, {"test_BenchmarkziplistValidateIntegrity", test_BenchmarkziplistValidateIntegrity}, {"test_BenchmarkziplistCompareWithString", test_BenchmarkziplistCompareWithString}, {"test_BenchmarkziplistCompareWithNumber", test_BenchmarkziplistCompareWithNumber}, {"test_ziplistStress__ziplistCascadeUpdate", test_ziplistStress__ziplistCascadeUpdate}, {NULL, NULL}};
unitTest __test_zipmap_c[] = {{"test_zipmapIterateWithLargeKey", test_zipmapIterateWithLargeKey}, {"test_zipmapIterateThroughElements", test_zipmapIterateThroughElements}, {NULL, NULL}};
unitTest __test_zmalloc_c[] = {{"test_zmallocInitialUsedMemory", test_zmallocInitialUsedMemory}, {"test_zmallocAllocReallocCallocAndFree", test_zmallocAllocReallocCallocAndFree}, {"test_zmallocAllocZeroByteAndFree", test_zmallocAllocZeroByteAndFree}, {NULL, NULL}};
Expand All @@ -275,7 +275,6 @@ struct unitTestSuite {
{"test_crc64combine.c", __test_crc64combine_c},
{"test_dict.c", __test_dict_c},
{"test_endianconv.c", __test_endianconv_c},
{"test_entry.c", __test_entry_c},
{"test_hashtable.c", __test_hashtable_c},
{"test_intset.c", __test_intset_c},
{"test_kvstore.c", __test_kvstore_c},
Expand All @@ -289,6 +288,7 @@ struct unitTestSuite {
{"test_util.c", __test_util_c},
{"test_valkey_strtod.c", __test_valkey_strtod_c},
{"test_vector.c", __test_vector_c},
{"test_volatile_set.c", __test_volatile_set_c},
{"test_ziplist.c", __test_ziplist_c},
{"test_zipmap.c", __test_zipmap_c},
{"test_zmalloc.c", __test_zmalloc_c},
Expand Down
Loading
Loading