Skip to content
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

Generate code that is friendlier to rustc's item_bodies_checking #34

Merged
merged 1 commit into from
Jan 8, 2019
Merged

Generate code that is friendlier to rustc's item_bodies_checking #34

merged 1 commit into from
Jan 8, 2019

Conversation

dotdash
Copy link
Contributor

@dotdash dotdash commented Jan 6, 2019

Having the Some() constructor in each match arm body puts extras stress
on rustc's item_bodies_checking pass. We can work around that by moving
the Some() constructor around the match, and directly returning None
from the default arm, which is the only one that generates a None value.

On my box, this almost cuts the time spent in item_bodies_checking in
half, going from about 8.7s to about 4.6s, and reduces the complete
compile time from about 13s to about 9s, so about a third less.

There are no changes in performance in cargo bench.

Note that doing the same for the composition_table() function does not
yield any compile time wins, but would cause a performance regression.

cc #29

Copy link
Contributor

@sujayakar sujayakar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome work, @dotdash! one comment inline asking for a comment, but otherwise lgtm.

@@ -315,14 +315,14 @@ def gen_decomposition_tables(canon_decomp, compat_decomp, out):
for table, name in tables:
out.write("#[inline]\n")
out.write("pub fn %s_fully_decomposed(c: char) -> Option<&'static [char]> {\n" % name)
out.write(" match c {\n")
out.write(" Some(match c {\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dotdash, can you add a comment here explaining the motivation for wrapping the match in Some? otherwise, it may look non-idiomatic to future readers of this codegen script.

@Manishearth
Copy link
Member

r=me with @sujayakar's comment addressed

Having the Some() constructor in each match arm body puts extras stress
on rustc's item_bodies_checking pass. We can work around that by moving
the Some() constructor around the match, and directly returning None
from the default arm, which is the only one that generates a None value.

On my box, this almost cuts the time spent in item_bodies_checking in
half, going from about 8.7s to about 4.6s, and reduces the complete
compile time from about 13s to about 9s, so about a third less.

There are no changes in performance in `cargo bench`.

Note that doing the same for the composition_table() function does not
yield any compile time wins, but would cause a performance regression.

cc #29
@dotdash
Copy link
Contributor Author

dotdash commented Jan 8, 2019

Added the requested comment, and adjusted the commit message to say that there is no change in performance, rather than in the generated assembly code, as --emit asm doesn't actually show that, because all the relevant functions are marked as #[inline], so there's only MIR generated for them.

@Manishearth Manishearth merged commit 4e72fd1 into unicode-rs:master Jan 8, 2019
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.

3 participants