-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Optimize write_metadata
.
#37267
Optimize write_metadata
.
#37267
Conversation
Measurements for a stage1 compiler doing debug builds:
So it's a big win for regex, a moderate win for syntax-incr, a small win for html5ever, and makes little difference to the others. (I did multiple timing runs and these outcomes were consistent.) |
.iter() | ||
.map(to_kind) | ||
.max() | ||
.unwrap(); |
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.
This could be written on one line, with the closure passed to it directly, and with no explicit type on the closure argument.
.max().unwrap()
would come on the same line after the })
where the }
is the closing bracket of the closure.
Also, you might want to do .unwrap_or(MetadataKind::None)
instead of .unwrap()
(cc @alexcrichton).
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 fixed the indentation.
@alexcrichton: the specific question is this: in write_metadata
, can cx.sess().crate_types
be empty?
`write_metadata` currently generates metadata unnecessarily in some cases, and also compresses it unnecessarily in some cases. This commit fixes that. It speeds up three of the rustc-benchmarks by 1--4%.
6fbad7e
to
016f69f
Compare
config::CrateTypeDylib | | ||
config::CrateTypeProcMacro => MetadataKind::Compressed, | ||
} | ||
}).max().unwrap(); |
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.
@alexcrichton r=me if the unwrap isn't wrong here.
@bors: r=eddyb On Tuesday, October 18, 2016, Eduard-Mihai Burtescu <
|
📌 Commit 016f69f has been approved by |
…ddyb Optimize `write_metadata`. `write_metadata` currently generates metadata unnecessarily in some cases, and also compresses it unnecessarily in some cases. This commit fixes that. It speeds up three of the rustc-benchmarks by 1--4%. r? @eddyb, who deserves much of the credit because he (a) identified the problem from the profile data I provided in rust-lang#37086, and (b) explained to me how to fix it. Thank you, @eddyb!
write_metadata
currently generates metadata unnecessarily in somecases, and also compresses it unnecessarily in some cases. This commit
fixes that. It speeds up three of the rustc-benchmarks by 1--4%.
r? @eddyb, who deserves much of the credit because he (a) identified the problem from the profile data I provided in #37086, and (b) explained to me how to fix it. Thank you, @eddyb!