-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add open addressing hash set #4705
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
base: main
Are you sure you want to change the base?
Conversation
72aad85
to
54db498
Compare
54db498
to
9e074cf
Compare
f487504
to
6237fbd
Compare
085ba97
to
02002f1
Compare
a42f779
to
c0eef55
Compare
5af11e2
to
b2dcb0f
Compare
1632b1d
to
9e3ef11
Compare
Key displacement
Fix set TTL tests
* feat: improve hash functions * feat: implement rehash via stored hash
60557e7
to
14554d9
Compare
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.
Looks promising.
However, besides that code, the comprehensive documentation must also be added. For example, what to do if a new type should be added?
It seems additional testing should be added, i.e. memory leaks.
// we can assume that high 12 bits of user address space | ||
// can be used for tagging. At most 52 bits of address are reserved for | ||
// some configurations, and usually it's 48 bits. | ||
// https://docs.kernel.org/arch/arm64/memory.html |
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.
Is that true for other hardware platforms? x86_64?
I guess this approach is useful (or even possible) for Linux only? I guess yes, so this is the performance update for Linux only. We have to have a general approach always to support cross-platform builds.
I think the build system should be updated to integrate this approach, to use it for Linux only.
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.
It's a crossplatform approach
auto* expiry_pos = Raw(); | ||
std::memcpy(expiry_pos, &at_sec, sizeof(at_sec)); |
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.
uint32_t* expiry_pos = Raw();
*expiry_pos = at_sec;
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.
with reinterpret_cast it will work. thx
if (IsVector()) { | ||
delete &AsVector(); | ||
} else { | ||
zfree(Raw()); | ||
} |
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.
Correct me, if I am wrong, but data_ always initializes with zmalloc, but not always frees with zfree.
This code looks dangerous.
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.
data_ can be vector whisch initializes with new or pointer to string which initializes with zmalloc. It looks dangerous, but it is ok
#4915
Added main functionality of OAHSet class
added tests
Current hash table is a classic open addressing hash table with linear probing, but with next modification:
For now, benchmarks are the next, but the code wasn't optimized for performance yet