-
Notifications
You must be signed in to change notification settings - Fork 919
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
rec: Compute size *estimate* for record cache allocated size #15038
base: master
Are you sure you want to change the base?
Conversation
b59ee2f
to
3a8ec14
Compare
Pull Request Test Coverage Report for Build 12768425464Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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.
One question but it looks very good!
pdns/dnsrecords.hh
Outdated
@@ -680,6 +850,11 @@ public: | |||
|
|||
static constexpr size_t const nbTypes = 65536; | |||
|
|||
[[nodiscard]] size_t sizeEstimate() const | |||
{ | |||
return d_bitset ? nbTypes / 8 : d_set.size() * (2U + sizeof(std::set<uint16_t>)); // XXX |
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.
I don't quite get the last part of the calculation here?
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 idea is: a set represented as a tree has size()
nodes. Each node is at least 2 bytes (to store the uint16_t value) plus the internal node data, which is estimated as being the roughly same size as the head node of type std::set<uint16_t>
. Come to think of it, the 2U is redundant as it is already included in sizeof(std::set<uint16_t>
. I'll check if there is a better estimate possible.
Short description
This implements a better computation of the metric
cache-bytes
. The existing one neglected the size of the individual records.This one might overestimate in some cases (string storage in string object itself) and underestimate because malloc bucket sizes, but at least it takes into account variable sized records.
Checklist
I have: