Skip to content

Fake PR to test integrate oah set branch#7247

Open
BorysTheDev wants to merge 2 commits intomainfrom
test_integrate_OAHSet_branch
Open

Fake PR to test integrate oah set branch#7247
BorysTheDev wants to merge 2 commits intomainfrom
test_integrate_OAHSet_branch

Conversation

@BorysTheDev
Copy link
Copy Markdown
Contributor

test changes from #7246

Copilot AI review requested due to automatic review settings April 30, 2026 13:42
@BorysTheDev BorysTheDev changed the title Fake PT to test integrate oah set branch Fake PR to test integrate oah set branch Apr 30, 2026
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 the runtime-selectable OAHSet backend for kEncodingStrMap2 SETs, updating server logic to operate on either StringSet or OAHSet via a shared dispatch layer.

Changes:

  • Introduces dfly::g_use_oah_set, VisitSet(), and Key() helpers to abstract over StringSet vs OAHSet.
  • Updates SET read/write paths, RDB save/load, journaling, and generic container iteration to use VisitSet() and set-time handling.
  • Extends async deletion and DEBUG SHRINK logic to attempt to support OAHSet-backed sets.

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 Switches dense-set time-touch to VisitSet() dispatch.
src/server/test_utils.cc Plumbs --use_oah_set into g_use_oah_set for tests.
src/server/set_family.h Changes ConvertToStrSet to return void* (StringSet/OAHSet).
src/server/set_family.cc Adds --use_oah_set, uses VisitSet() throughout SET ops, and builds dense sets as StringSet/OAHSet.
src/server/server_family.cc Adapts DEBUG SHRINK to handle OAHSet-backed SETs.
src/server/rdb_save.cc Uses VisitSet() for SET expiry/type decisions and serialization.
src/server/rdb_load.cc Loads dense sets as either StringSet or OAHSet depending on g_use_oah_set.
src/server/journal/cmd_serializer.cc Uses VisitSet() to disable/restore lazy expiry during set serialization.
src/server/generic_family.cc Uses VisitSet() to set dense-set time before iterating set elements.
src/server/dfly_main.cc Initializes g_use_oah_set from --use_oah_set at startup.
src/server/db_slice.cc Extends async deletion to support OAHSet via templated deleter callbacks.
src/server/container_utils.cc Iterates dense sets via VisitSet() and Key() extraction.
src/server/collection_family_fallback.cc Updates fallback signature for ConvertToStrSet to void*.
src/core/oah_set_test.cc Renames alloc accounting APIs in tests to ObjMallocUsed/SetMallocUsed.
src/core/oah_set.h Adds VisitSet(), Key(), inline g_use_oah_set, and iterator expiry-on-advance.
src/core/compact_object.cc Uses VisitSet() for freeing, defrag, and size computation of dense sets.

Comment thread src/server/db_slice.cc
Comment on lines +279 to +286
auto step = +[](ClearNode* n) {
auto* s = static_cast<Set*>(n->ds);
n->cursor = s->ClearStep(n->cursor, kClearStepSize);
if (n->cursor == s->BucketCount()) {
CompactObj::DeleteMR<Set>(s);
return true;
}
return false;
Comment thread src/server/db_slice.cc
Comment on lines +1841 to +1847
auto schedule = [](auto* ds) {
uint32_t next = ds->ClearStep(0, 512);
if (next < ds->BucketCount())
AsyncDeleter::EnqueDeletion(next, ds);
else
CompactObj::DeleteMR<std::remove_pointer_t<decltype(ds)>>(ds);
};
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*);
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Apr 30, 2026

🤖 Augment PR Summary

Summary: Makes the dense SET backing implementation runtime-selectable, enabling OAHSet as an alternative to StringSet via a new --use_oah_set flag.

Changes:

  • Add `g_use_oah_set`, `VisitSet()`, and `Key()` helpers to dispatch `kEncodingStrMap2` SET operations to either `StringSet` or `OAHSet`
  • Update core object plumbing (free, malloc-used, defrag, size) to work with the selected dense-set type
  • Thread the flag into server startup and test setup
  • Refactor SET command implementation and container iteration to use `VisitSet()` rather than direct `StringSet*` casts
  • Adjust RDB load/save and journaling serialization to iterate/serialize both dense-set variants and preserve per-member expiry data
  • Generalize async deletion/shrink handling to support `OAHSet`-backed SETs

Technical Notes: OAHSet iteration now performs lazy per-member expiry when time_now_ is non-zero; memory counters were renamed to ObjMallocUsed/SetMallocUsed.

🤖 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. 3 suggestions posted.

Fix All in Augment

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

Comment thread src/server/db_slice.cc
auto step = +[](ClearNode* n) {
auto* s = static_cast<Set*>(n->ds);
n->cursor = s->ClearStep(n->cursor, kClearStepSize);
if (n->cursor == s->BucketCount()) {
Copy link
Copy Markdown

@augmentcode augmentcode Bot Apr 30, 2026

Choose a reason for hiding this comment

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

For OAHSet, ClearStep() advances cursor up to Capacity() (entries_.size), but this code compares against BucketCount() (2^capacity_log) which is smaller; that can terminate early and delete the set while displacement buckets still contain live entries. This looks like it can leak memory and/or leave dangling state during async deletion.

Severity: high

Other Locations
  • src/server/db_slice.cc:1843
  • src/server/db_slice.cc:1846

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

PrimeValue& pv = it_res.it->second;
DenseSet* ds = static_cast<DenseSet*>(pv.RObjPtr());
ds->set_time(MemberTimeSeconds(t->GetDbContext().time_now_ms));
size_t bucket_bytes_before = ds->BucketCount() * sizeof(void*);
Copy link
Copy Markdown

@augmentcode augmentcode Bot 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 uses BucketCount() * sizeof(void*), but OAHSet allocates Capacity() buckets of OAHEntry (including the displacement area), so the reported reclaimed bytes for SHRINK will be inaccurate under --use_oah_set. Consider ensuring the reported delta matches the container’s actual bucket-storage allocation.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread src/server/dfly_main.cc
LOG(WARNING) << "SWAP is enabled. Consider disabling it when running Dragonfly.";

dfly::max_memory_limit = absl::GetFlag(FLAGS_maxmemory);
dfly::g_use_oah_set = absl::GetFlag(FLAGS_use_oah_set);
Copy link
Copy Markdown

@augmentcode augmentcode Bot Apr 30, 2026

Choose a reason for hiding this comment

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

The PR title/description look like placeholders and don’t describe the change intent, which makes the review/audit trail hard to follow. Please align with the repo PR guideline that titles be descriptive and summaries explain what/why (Rule: AGENTS.md).

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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