Skip to content

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

Merged
merged 1 commit into from
Sep 27, 2013

Conversation

alexcrichton
Copy link
Member

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.

@alexcrichton
Copy link
Member Author

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);
Copy link
Member

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?

Copy link
Member Author

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.

@flaper87
Copy link
Contributor

bump, This may need to be rebased.

};

task.logger.log(SendStrOwned(msg));
match task.name {
Copy link
Member

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.
@alexcrichton
Copy link
Member Author

This is blocked on #9484

bors added a commit that referenced this pull request Sep 27, 2013
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.
@bors bors closed this Sep 27, 2013
@bors bors merged commit eb2b25d into rust-lang:master Sep 27, 2013
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 this pull request may close these issues.

4 participants