-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Refactor the logging system for fewer allocations #9261
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
Conversation
This will fail to bootstrap unless #9257 lands first. |
@@ -140,22 +168,21 @@ pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! { | |||
let msg = str::raw::from_c_str(msg); | |||
let file = str::raw::from_c_str(file); |
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.
Loosely related to this change: these actually allocate a new buffer, would it be possible for begin_unwind_
to be passed Rust strings and uints rather than C ones?
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.
That would be a nice change actually, it seems fairly nicely separable from this change, however, so I think I'd attempt to do it in a later commit.
bump, This may need to be rebased. |
}; | ||
|
||
task.logger.log(SendStrOwned(msg)); | ||
match task.name { |
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 this become something like
let name = task.name.map(|s| s.as_slice()).unwrap_or("<unnamed>");
format_args!(|arg| { ... }, "...", name, msg, file, line);
This lifts various restrictions on the runtime, for example the character limit when logging a message. Right now the old debug!-style macros still involve allocating (because they use fmt! syntax), but the new debug2! macros don't involve allocating at all (unless the formatter for a type requires allocation.
This is blocked on #9484 |
This lifts various restrictions on the runtime, for example the character limit when logging a message. Right now the old debug!-style macros still involve allocating (because they use fmt! syntax), but the new debug2! macros don't involve allocating at all (unless the formatter for a type requires allocation.
This lifts various restrictions on the runtime, for example the character limit
when logging a message. Right now the old debug!-style macros still involve
allocating (because they use fmt! syntax), but the new debug2! macros don't
involve allocating at all (unless the formatter for a type requires allocation.