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

Performance regressions in nightly btwn nightly-2017-12-25 and nightly-2017-12-26 #48155

Closed
lloydmeta opened this issue Feb 12, 2018 · 2 comments
Labels
C-bug Category: This is a bug. I-slow Issue: Problems and improvements with respect to performance of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lloydmeta
Copy link
Member

lloydmeta commented Feb 12, 2018

I think this is the right place to report that I am seeing some performance regressions in Frunk, namely in the benchmark for LabelledGeneric-based conversions, where I compare hand-written conversions between structs vs auto LabelledGeneric-driven conversions.

I've narrowed it to changes made between nightly-2017-12-25 and nightly-2017-12-26

$ cargo +nightly-2017-12-25 bench big
running 4 tests
test big_from_24fields           ... bench:         128 ns/iter (+/- 10)
test big_from_25fields           ... bench:         159 ns/iter (+/- 27)
test big_transform_from_24fields ... bench:         136 ns/iter (+/- 68)
test big_transform_from_25fields ... bench:         186 ns/iter (+/- 36)

$ cargo +nightly-2017-12-26 bench big
test big_from_24fields           ... bench:         149 ns/iter (+/- 32)
test big_from_25fields           ... bench:         188 ns/iter (+/- 44)
test big_transform_from_24fields ... bench:       7,631 ns/iter (+/- 3,917)
test big_transform_from_25fields ... bench:       9,162 ns/iter (+/- 4,136)

As you can see above, the LabelledGeneric-based conversion (big_transform_from_*) went from being essentially the same as hand-written to ~70x the overhead 😢

Not really sure if it matters how LabelledGeneric struct-to-struct transformation works in Frunk, but it essentially gets the compiler to verify that for two given structs, their fields are "compatible" (target struct field names and fields types are a subset of source struct's) and then "just" aligns the generic representation of source to target and dumps one into the other. I say "just" because I still have no idea how Rust managed to make this a zero-overhead op 😆

The bloody details are available in multipart on my blog (part 1, part 2, part 3).

@alexcrichton
Copy link
Member

Thanks for the report! I was able to "fix" the regession by setting codegen-units = 1, which means this is probably due to #47745

@pietroalbini pietroalbini added I-slow Issue: Problems and improvements with respect to performance of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Feb 13, 2018
@Enselic
Copy link
Member

Enselic commented Sep 26, 2023

Triage: Yes, let's close as duplicate of #47745.

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-slow Issue: Problems and improvements with respect to performance of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants