-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Replace mem.page_size with mem.min_page_size and mem.max_page_size #3815
Changes from all commits
6e33c21
af76413
97ac04b
9ce8488
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 |
---|---|---|
|
@@ -8,11 +8,31 @@ const meta = std.meta; | |
const trait = meta.trait; | ||
const testing = std.testing; | ||
|
||
pub const page_size = switch (builtin.arch) { | ||
pub const min_page_size = switch (builtin.arch) { | ||
.mips, .mipsel, .mips64, .mips64el => switch (builtin.os) { | ||
else => 1024, // NEC VR41xx processors support as low as 1K page size | ||
.linux => 4 * 1024, // Linux doesn't support < 4K pages | ||
}, | ||
.sparcv9 => 8 * 1024, | ||
.wasm32, .wasm64 => 64 * 1024, | ||
else => 4 * 1024, | ||
}; | ||
|
||
pub const max_page_size = switch (builtin.arch) { | ||
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. can you justify the inclusion of this constant? The one place you used it, I disagree with. That test should be using actual page size. 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. What do you mean by "actual page size"? |
||
.arm, .armeb => 16 * 1024 * 1024, // At least ARMv7 has optional support for 16M pages | ||
.aarch64, .aarch64_be => 1 * 1024 * 1024 * 1024, // ARM64 supports 4K, 16K, 64K, 2M, 32M, 512M, 1G pages | ||
.mips, .mipsel, .mips64, .mips64el => 64 * 1024, // Every MIPS III, MIPS IV, MIPS32 and MIPS64 processor supports 4K, 16K and 64K page sizes. | ||
.powerpc64, .powerpc64le => 64 * 1024, | ||
.s390x => 2 * 1024 * 1024 * 1024, // 4K, 1M, 2G pages | ||
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. Fun fact: this doesn't fit in a |
||
.sparcv9 => 16 * 1024 * 1024 * 1024, // 8K, 64K, 512K, 4M, 32M, 256M, 2G, 16G | ||
.wasm32, .wasm64 => 64 * 1024, | ||
.x86_64 => 1 * 1024 * 1024 * 1024, // 1G huge pages. | ||
else => min_page_size, | ||
}; | ||
|
||
/// A good default size for buffers | ||
pub const bufsiz = min_page_size; | ||
|
||
pub const Allocator = struct { | ||
pub const Error = error{OutOfMemory}; | ||
|
||
|
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 removed this
* 6
... it seemed oddly arbitrary.