Skip to content
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

Is it a bug of not checking against max bucket and lock power ? #125

Closed
wenhaocs opened this issue Mar 22, 2022 · 5 comments
Closed

Is it a bug of not checking against max bucket and lock power ? #125

wenhaocs opened this issue Mar 22, 2022 · 5 comments

Comments

@wenhaocs
Copy link
Contributor

wenhaocs commented Mar 22, 2022

There is a way of setting AccessConfig via number of estimated cache entries. However, unlike directly passing bucketPower and lockPower, the calculated bucketPower and lockPower is not checked against maximum. Is it a potential bug?
https://sourcegraph.com/github.com/facebook/CacheLib/-/blob/cachelib/allocator/CacheAllocatorConfig.h?L625

@sathyaphoenix
Copy link
Contributor

@wenhaocs good catch. Do you mind sending a PR to address that and I can merge it.

@wenhaocs
Copy link
Contributor Author

@sathyaphoenix Please let me know if you want to throw error explicitly and tell users the limit for #cacheEntries, or just implicitly set the bucketPower to be maximum like in the PR.

@jiayuebao
Copy link
Contributor

jiayuebao commented Apr 4, 2022

@wenhaocs Shall we use std::min instead of std::max to pick the smaller value?

@sathyaphoenix
Copy link
Contributor

To be consistent with the constructor, it makes sense to throw an error when the value is going to be incorrect rather than silently fix it. Most likely in this case the user gave a wrong input and it is better to abort rather than silently run with a misconfigured hash table. Also, like @jiayuebao pointed out, we should be doing a std::min instead of max if we were to adjust to a meaningful value.

@wenhaocs can you add a simple unit test for this ? we can introduce a new .cpp here to add CacheAllocatorConfig unit tests. @jiayuebao please let us know if there is a better place to add the test.

@jiayuebao
Copy link
Contributor

For unit test, we already have one here. And we can add more cases there.

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 a pull request may close this issue.

3 participants