Skip to content

feat: integrate OAHSet#7246

Open
BorysTheDev wants to merge 2 commits intomainfrom
integrate_OAHSet
Open

feat: integrate OAHSet#7246
BorysTheDev wants to merge 2 commits intomainfrom
integrate_OAHSet

Conversation

@BorysTheDev
Copy link
Copy Markdown
Contributor

@BorysTheDev BorysTheDev commented Apr 30, 2026

Summary: This PR integrates OAHSet as an optional dense backing store for kEncodingStrMap2 SETs behind a new --use_oah_set flag.

Changes:

  • Adds g_use_oah_set (startup snapshot) plus VisitSet/Key helpers to dispatch between StringSet and OAHSet
  • Updates SET command paths and generic iteration utilities to work with either dense-set implementation
  • Extends async deletion, defrag, size/memory accounting, and SHRINK logic to support OAHSet-backed SETs
  • Updates RDB save/load and journal serialization to iterate/serialize dense sets via the new dispatch helpers
  • Renames OAHSet memory counters to ObjMallocUsed/SetMallocUsed and adjusts unit tests accordingly

the results of use_oah_set=true are in fake PR #7247

Copilot AI review requested due to automatic review settings April 30, 2026 12:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Integrates OAHSet as an optional runtime-selected backing implementation for dense SETs (kEncodingStrMap2) behind a new --use_oah_set flag, and adapts server paths (commands, RDB/journal, deletion/defrag) to operate over either StringSet or OAHSet via VisitSet() dispatch.

Changes:

  • Introduces --use_oah_set and a global snapshot (dfly::g_use_oah_set) to select the concrete dense-set type at startup.
  • Updates SET-related operations (iteration, expiry touch, serialization, conversion from intset/listpack) to be generic over StringSet/OAHSet.
  • Extends core memory accounting/defrag/free paths to handle the new dense-set implementation.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/server/zset_family.cc Uses VisitSet to set dense-set time before iterating members for ZSET ops involving SET inputs.
src/server/test_utils.cc Plumbs FLAGS_use_oah_set into g_use_oah_set for tests.
src/server/set_family.h Updates ConvertToStrSet API to return a type-erased pointer for StringSet/OAHSet.
src/server/set_family.cc Adds flag definition, generic dense-set wrappers/helpers, and supports building dense sets as OAHSet.
src/server/server_family.cc Updates SERVER SHRINK to support shrinking OAHSet-backed SETs.
src/server/rdb_save.cc Serializes SETs via VisitSet, including expiry-aware type selection.
src/server/rdb_load.cc Loads dense SETs into either StringSet or OAHSet depending on g_use_oah_set.
src/server/journal/cmd_serializer.cc Disables/restores lazy expiry for dense SET serialization via VisitSet.
src/server/generic_family.cc Ensures dense SET expiry time is touched before container iteration via VisitSet.
src/server/dfly_main.cc Wires FLAGS_use_oah_set into dfly::g_use_oah_set at startup.
src/server/db_slice.cc Extends async deletion logic to support OAHSet via templated AsyncDeleter.
src/server/container_utils.cc Iterates dense SETs via VisitSet and common Key(it) extraction.
src/server/collection_family_fallback.cc Updates fallback signature for ConvertToStrSet.
src/core/oah_set_test.cc Renames alloc accounting APIs in tests to ObjMallocUsed / SetMallocUsed.
src/core/oah_set.h Adds lazy-expiry during iteration, exposes malloc-used APIs, and introduces VisitSet/Key helpers + g_use_oah_set.
src/core/compact_object.cc Updates free/size/defrag logic for dense SETs to dispatch via VisitSet.

Comment thread src/server/db_slice.cc
Comment thread src/server/db_slice.cc Outdated
Comment thread src/server/server_family.cc Outdated
Comment on lines +2880 to +2883
size_t bucket_bytes_before = ds->BucketCount() * sizeof(void*);
size_t optimal_size = std::max(size_t(8), absl::bit_ceil(ds->UpperBoundSize()));
ds->Shrink(optimal_size);
size_t bucket_bytes_after = ds->BucketCount() * sizeof(void*);
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bucket_bytes_before/after is computed as BucketCount() * sizeof(void*), which is not valid for OAHSet (buckets are OAHEntry, not pointers). This makes the SHRINK reply (freed bytes) incorrect under --use_oah_set; consider using SetMallocUsed() before/after shrink (available on both DenseSet and OAHSet) or otherwise accounting based on the actual bucket element size.

Copilot uses AI. Check for mistakes.
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Apr 30, 2026

🤖 Augment PR Summary

Summary: Adds an optional OAHSet backing for kEncodingStrMap2 SET values, gated by a new --use_oah_set flag, while keeping existing behavior as the default.

Changes:

  • Introduces dfly::g_use_oah_set (startup snapshot) plus VisitSet()/Key() helpers to dispatch between StringSet and OAHSet
  • Updates SET command paths and generic iteration utilities to work with either dense-set implementation
  • Extends async deletion to handle both dense-set types (including correct end-cursor handling for OAHSet)
  • Updates defrag, size/memory accounting, and SHRINK to support OAHSet-backed SETs
  • Updates RDB save/load and journal serialization to iterate/serialize dense sets via the new dispatch helpers
  • Renames OAHSet memory counters to ObjMallocUsed/SetMallocUsed and adjusts unit tests

Technical Notes: OAHSet iterators now perform lazy member-expiry when time_now is enabled; serialization paths temporarily disable expiry via set_time(0) to avoid mutation during iteration.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread src/server/server_family.cc Outdated
Comment thread src/server/rdb_save.cc
@BorysTheDev
Copy link
Copy Markdown
Contributor Author

augment review

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread src/core/oah_set.h
Comment thread src/server/server_family.cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants