Skip to content

Add helloworld-tiny benchmark #1413

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 7, 2022
Merged

Add helloworld-tiny benchmark #1413

merged 1 commit into from
Sep 7, 2022

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented Aug 18, 2022

Now that we finally have size artifact metrics in the DB, I think that we should also add some benchmarks that will specifically be focused on artifact sizes. I think that for starters it would be nice to measure the size of a small binary (either a helloworld or a completely empty one) and some reasonably common Rust binary (like ripgrep, since we already have it).

@Kobzol Kobzol requested a review from Mark-Simulacrum August 18, 2022 11:39
@rylev
Copy link
Member

rylev commented Aug 18, 2022

I'm in favor of this change. I think having a different scenario feels like the most appropriate given that we already have variable scenarios depending on which benchmark is being tested.

@Kobzol
Copy link
Contributor Author

Kobzol commented Aug 18, 2022

How should it work in terms of selecting which benchmark should run? If we just add a hard-coded MinSize scenario and pass it in <command> --scenarios Full,IncrFull,...,MinSize, then it would be executed for all benchmarks by default, which is probably not what we want.

We could add something like additional-scenarios to the perf-config.json of the existing helloworld benchmark:

{
    "category": "primary",
    "additional-scenarios": [{
        "profile": "Opt",
        "env": {
          "CARGO_PROFILE_RELEASE_STRIP": "abort",
          ...
        }
    }]
}

And execute these scenarios for the selected profile unconditionally?

Or we can just hardcode selected benchmarks that will be executed with the MinSize scenario in collector/collect.sh:

target/release/collector bench_next $SITE_URL --self-profile --bench-rustc --db $DATABASE --scenarios Full,IncrFull,IncrPatched,IncrUnchanged
target/release/collector bench_next $SITE_URL --self-profile --bench-rustc --db $DATABASE --benchmarks helloworld,ripgrep --scenarios MinSize --profiles Opt

@nnethercote
Copy link
Contributor

  1. Just create new benchmark that will use size-optimizing compile flags (LTO=fat, CGU=1, opt-level=z, strip=true, panic=abort) in its Cargo.toml. This is what this PR currently does.

I think this is the right thing to do for now. We can try it out for a while with one or two benchmarks, and see how it goes. That's a lot easier than building extra machinery (new profile/scenario/category) that (a) is only needed for a couple of benchmarks, and (b) might turn out to be a poor choice.

The good thing is that we don't have to build any new infrastructure, we just add new benchmarks.

👍

The worse thing is that the benchmark will be unnecessarily executed in modes that are mostly not interesting for the final binary size (doc, check, incremental builds). It might also not be immediately clear from the benchmark that we should care about its size:object_file metric. We might name them like <benchmark>-tiny or <benchmark>-size, but that might not be visible enough.

So are the only cases we're interested in debug full and opt full? For a start, get rid of the 0-println.patch file and that will avoid the incr-patched measurements 😃

We could also add some way to exclude measurements in the perf-config.json, e.g. exclude-profile and exclude-scenario options. (Or maybe include-profile/include-scenario instead, and the default is everything.)

What's maybe worse is that these benchmarks will use compilation flags that we don't normally benchmark (LTO, CGU, etc.). When some regression happens only for these flags, it might be difficult to realize from the benchmark description that it actually uses these flags, since they will use the normal scenarios and profiles.

I'm not too worried about that. rustc-perf contributors and triagers will learn quickly, and we're accustomed to normal compiler devs not understanding the perf numbers as well. And we have descriptions of the benchmarks in the documentation.

@Kobzol

This comment was marked as off-topic.

@Kobzol Kobzol marked this pull request as ready for review September 1, 2022 20:07
@Kobzol Kobzol force-pushed the size-benchmarks branch 2 times, most recently from 8bbfcca to d2f1e31 Compare September 5, 2022 22:24
Copy link
Contributor

@nnethercote nnethercote left a comment

Choose a reason for hiding this comment

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

Is it interesting to include Debug?

Also, you've excluded some profiles but not some scenarios, was that deliberate?

@Kobzol
Copy link
Contributor Author

Kobzol commented Sep 6, 2022

I think that ignoring scenarios is not meeded here, since there is no patch file? But probably IncrFull will still be executed, hmm, didn't think of that.

I'm not sure if binary size is that interesting for Debug (maybe for embedded?).

@nnethercote
Copy link
Contributor

nnethercote commented Sep 6, 2022

Removing the patch file eliminates the IncrPatched scenario, but the IncrFull and IncrUnchanged ones will still run, as well as the non-incremental Full.

@Kobzol
Copy link
Contributor Author

Kobzol commented Sep 6, 2022

Thanks, I missed that. I will send another PR with scenario exclusion.

@Kobzol
Copy link
Contributor Author

Kobzol commented Sep 6, 2022

Now both uninteresting profiles and scenarios are filtered out.

@Kobzol Kobzol merged commit d41f1bf into master Sep 7, 2022
@Kobzol Kobzol deleted the size-benchmarks branch September 7, 2022 18:29
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