-
Notifications
You must be signed in to change notification settings - Fork 22
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
No 4096 #125
Conversation
Good changes. My only question is if this should be defined in |
Is there a good reason to not stick the constant into a namespace? Not polluting the default namespace sounds like a good idea for such a generic name. Also, as we are trying to improve coding style, this might be a good opportunity to change our coding style document and follow the more modern advice [1] to use lower case for constants, to avoid clashes with any preprocessor macros. This can be done in a mass commit later, of course, but would then touch all these lines again. |
No, there is not. Actually, this is something I wanted to mention in the commit message but forgot. Of course it should be. Since there are two (very) related issues here, can we first decide on which header file this should be? Any suggestion? Secondly, I think we should clean up Finally, regarding:
let me mention that this was probably the first time that I did follow the code style document, but now we do not like that particular part of it anymore ;-) |
Sorry for the messy comment, I tried to factor out the sidetracking to the bottom, but either I send this now, or I delete it entirely. I thought about Subjectively I think it feels better outside the backend namespace, as it is a hardware detail and not a backend detail, but I don't think this is a strong argument.
[1] we have the memfd-syscall, which is currently handled in a linux-specific way (in |
This constant is used for the size of a page, but was hard-coded in various places using various forms (4096, 4096UL, ...). Also, various header files used different definitions / names for it (pagesize, page_size, PAGESIZE). This commit adds a `PAGE_SIZE` constexpr and uses it in all `src` files. Addresses the biggest part of #49. (Does not deal with CACHELINE.)
I opened #128 on |
Given that |
Unless we see any reason for I suggest we leave it in EDITED (TWICE): On a second thought, perhaps it's better to leave it outside the backend's namespace. Also, note that constexpr std::size_t PAGE_SIZE = sysconf(_SC_PAGE_SIZE); // this does not work because it's not statically evaluated or we can even completely remove this definition and use some configure-time-evaluated expression from |
Ok, since no one has come up with a better solution it can be left where it is. |
To avoid polluting the namespace and also avoid all discussions on which header file is best to include the definition of the PAGE_SIZE constant, we instead pass it as a command-line definition. We also hard-code its value because we want to ensure it is an unsigned, rather than integer that the commented out code to get it from the environment or a simple 4096 would default to.
After some thought and some discussion, we decided that it is best to not define a constant |
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 think the latest proposed solution is OK. It also circumvents the issue of which file and namespace this should be declared in. I will approve it but perhaps give @davidklaftenegger a chance to respond before merging.
Eliminate all uses of the magic 4096 constant
This constant is used for the size of a page, but was hard-coded in
various places using various forms (4096, 4096UL, ...). Also, various
header files used different definitions / names for it (pagesize,
page_size, PAGESIZE).
This commit adds a
PAGE_SIZE
constexpr and uses it in allsrc
files.Addresses the biggest part of #49. (Does not deal with CACHELINE.)