Optimize logging codegen #276

Merged
sfackler merged 1 commit from codegen into master 2018-06-05 00:40:02 -05:00
sfackler commented 2018-06-03 12:59:15 -05:00 (Migrated from github.com)

The extra work involved in loading the logger and creating the record
struct involves move codegen than is necessary if we take this kind of
approach (which we previously used in 0.3). It's a bit unfortunate to
have these public-but-not-public functions, but I think it's worth it.
We want to minimize the footprint of logging so people feel comfortable
using it!

A main function containing nothing but warn!("hello world") shrinks
from 204 bytes to 124 bytes in x86_64 with this change.

Closes #275

The extra work involved in loading the logger and creating the record struct involves move codegen than is necessary if we take this kind of approach (which we previously used in 0.3). It's a bit unfortunate to have these public-but-not-public functions, but I think it's worth it. We want to minimize the footprint of logging so people feel comfortable using it! A main function containing nothing but `warn!("hello world")` shrinks from 204 bytes to 124 bytes in x86_64 with this change. Closes #275
sfackler commented 2018-06-03 12:59:23 -05:00 (Migrated from github.com)

r? @KodrAus

r? @KodrAus
KodrAus (Migrated from github.com) approved these changes 2018-06-03 16:47:38 -05:00
KodrAus (Migrated from github.com) left a comment

This looks good to me! Do you think it's worth leaving a comment on __private_api_log motivating it as reducing generated code size in crates that use log?

This looks good to me! Do you think it's worth leaving a comment on `__private_api_log` motivating it as reducing generated code size in crates that use `log`?
sfackler commented 2018-06-03 17:19:10 -05:00 (Migrated from github.com)

I generally like to use git-blame for that kind of background, but it also seems fine to add.

I generally like to use git-blame for that kind of background, but it also seems fine to add.
KodrAus commented 2018-06-03 18:02:18 -05:00 (Migrated from github.com)

git-blame seems reasonable to me 👍

git-blame seems reasonable to me :+1:
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-rust-lang/log!276
No description provided.