-
Notifications
You must be signed in to change notification settings - Fork 998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: simplify BumpUps deduplication #4098
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -592,14 +592,27 @@ class DbSlice { | |
|
||
DbTableArray db_arr_; | ||
|
||
struct FpHasher { | ||
size_t operator()(uint64_t val) const { | ||
return val; | ||
} | ||
}; | ||
|
||
// Used in temporary computations in Acquire/Release. | ||
mutable absl::flat_hash_set<uint64_t> uniq_fps_; | ||
mutable absl::flat_hash_set<uint64_t, FpHasher> uniq_fps_; | ||
|
||
// ordered from the smallest to largest version. | ||
std::list<std::pair<uint64_t, ChangeCallback>> change_cb_; | ||
|
||
// Used in temporary computations in Find item and CbFinish | ||
mutable absl::flat_hash_set<CompactObjectView> fetched_items_; | ||
// This set is used to hold fingerprints of key accessed during the run of | ||
// a transaction callback (not the whole transaction). | ||
// We track them to avoid bumping them again (in any direction) so that the iterators to | ||
// the fetched keys will not be invalidated. We must do it for atomic operations, | ||
// for operations that preempt in the middle we have another mechanism - | ||
// auto laundering iterators, so in case of preemption we do not mind that fetched_items are | ||
// cleared or changed. | ||
mutable absl::flat_hash_set<uint64_t, FpHasher> fetched_items_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets add a comment why we need this hashset , why we can not bumpup item twice in transaction without preemption but ok to to bumpup twice when we do preempt There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. expect this comment the changes looks ok and we can merge |
||
|
||
// Registered by shard indices on when first document index is created. | ||
DocDeletionCallback doc_del_cb_; | ||
|
@@ -632,6 +645,24 @@ class DbSlice { | |
absl::container_internal::hash_default_hash<std::string>, | ||
absl::container_internal::hash_default_eq<std::string>, AllocatorType> | ||
client_tracking_map_; | ||
|
||
class PrimeBumpPolicy { | ||
public: | ||
PrimeBumpPolicy(absl::flat_hash_set<uint64_t, FpHasher>* items) : fetched_items_(items) { | ||
} | ||
|
||
// returns true if we can change the object location in dash table. | ||
bool CanBump(const CompactObj& obj) const { | ||
if (obj.IsSticky()) { | ||
return false; | ||
} | ||
auto hc = obj.HashCode(); | ||
return fetched_items_->insert(hc).second; | ||
} | ||
|
||
private: | ||
mutable absl::flat_hash_set<uint64_t, FpHasher>* fetched_items_; | ||
}; | ||
}; | ||
|
||
inline bool IsValid(const DbSlice::Iterator& it) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the default hasher?
(I get that this is not the core of this draft PR, still I'm curious :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default one hashes :)
I find it redundant for keys that are already mixed (results of a hash function )