-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Switch to direct HeapAlloc on Windows when not using jemalloc #26265
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -395,6 +425,12 @@ mod imp { | |||
} | |||
|
|||
pub fn stats_print() {} |
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 would provide a really neat implementation using HeapSummary
, but I don't know of an easy way to print things from inside this crate.
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 there no easy way to write to stdout on windows without the CRT?
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.
Well I could directly WriteConsole
to GetStdHandle(STD_OUTPUT_HANDLE)
but then I'd have to format numbers into strings without std
.
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 it's fine to leave this as-is, I don't think it's really worth adding an implementation unless it's easy (this is very rarely called)
Did you consulted with the implementations of |
Looks mostly like optimisations, backward compatibility, crt specifics, and locking (in case NO_SERIALIZE heap is misused?) code. Since this code currently can only be used by the standard library, I feel its fine to go for the simple approach. |
Thanks @retep998! It's my impression that the CRT Also, could you elaborate a little more on why we want to eliminate the dependency on the CRT? It sounds like issues like #26258 mean that it'd be nice to not have to deal with it altogether, but I just want to make sure we've got a good picture of what's going on here. |
I want to eliminate the dependency on the CRT so that Rust can be independent of it. Such a Rust library could be used anywhere without concerns over the ABI of the C runtime. A binary built without the CRT and having its own entry point wouldn't depend on the CRT redistributables and would have a quicker startup time. |
|
||
#[inline] | ||
unsafe fn align_ptr(ptr: *mut u8, align: usize) -> *mut u8 { | ||
let aligned = ptr.offset((align - (ptr as usize & align - 1)) as isize); |
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.
Could you add some parens to the align - 1
just to make the binding explicit? (I can never remember the precedence of -
vs &
Sounds good to me! r=me with just a few nits |
Signed-off-by: Peter Atashian <retep998@gmail.com>
Nits addressed and an implementation of |
cc #20861 |
This removes our dependency on the CRT for memory allocation.
This removes our dependency on the CRT for memory allocation.