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

MetadataOnlyCodegenBackend: run the collector only once #57418

Merged
merged 2 commits into from Jan 14, 2019

Conversation

Projects
None yet
8 participants
@lqd
Copy link
Contributor

lqd commented Jan 7, 2019

Use the collect_and_partition_mono_items query to avoid calling the collector directly twice.

Fixes #57406.

Codegen: run the collector only once
Use the `collect_and_partition_mono_items ` query to avoid calling the collector
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 7, 2019

r? @cramertj

(rust_highfive has picked a reviewer for you, use r? to override)

@@ -136,24 +135,15 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
::symbol_names_test::report_symbol_names(tcx);
::rustc_incremental::assert_dep_graph(tcx);
::rustc_incremental::assert_module_sources::assert_module_sources(tcx);
::rustc_mir::monomorphize::assert_symbols_are_distinct(tcx,

This comment has been minimized.

@nagisa

nagisa Jan 7, 2019

Contributor

Note to anybody looking through this: collect_and_partition_mono_items query does this assert internally.

@cramertj

This comment has been minimized.

Copy link
Member

cramertj commented Jan 7, 2019

@lqd

This comment has been minimized.

Copy link
Contributor

lqd commented Jan 7, 2019

(At least this basic first Travis pass seems to work, so I'm removing the WIP-ness)

@lqd lqd changed the title [WIP] codegen-backend: run the collector only once codegen-backend: run the collector only once Jan 7, 2019

@michaelwoerister

This comment has been minimized.

Copy link
Contributor

michaelwoerister commented Jan 8, 2019

Thanks a lot, @lqd! Let's see if we can notice a performance difference.

@bors try

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 8, 2019

⌛️ Trying commit c075e24 with merge 85cebe1...

bors added a commit that referenced this pull request Jan 8, 2019

Auto merge of #57418 - lqd:collector_query, r=<try>
codegen-backend: run the collector only once

Use the `collect_and_partition_mono_items` query to avoid calling the collector directly twice.

Fixes #57406.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 8, 2019

☀️ Test successful - status-travis
State: approved= try=True

@michaelwoerister

This comment has been minimized.

Copy link
Contributor

michaelwoerister commented Jan 8, 2019

@rust-timer

This comment has been minimized.

Copy link

rust-timer commented Jan 8, 2019

Success: Queued 85cebe1 with parent 9d54812, comparison URL.

@bjorn3

This comment has been minimized.

Copy link
Contributor

bjorn3 commented Jan 8, 2019

This will not have any perf change, because this is not the llvm codegen backend, but a backend only emitting metadata introduced in #44085. You have to pass -Zcodegen-backend=metadata_only to use it. Its probably broken at the moment anyway.

Edit: correct debug flag.

@rust-timer

This comment has been minimized.

Copy link

rust-timer commented Jan 8, 2019

Finished benchmarking try commit 85cebe1

@michaelwoerister

This comment has been minimized.

Copy link
Contributor

michaelwoerister commented Jan 8, 2019

Oh, it's a different backend...

Well, does it rely on collection being eager? Why does it even monomorphize items in the first place?

@bjorn3

This comment has been minimized.

Copy link
Contributor

bjorn3 commented Jan 8, 2019

Well, does it rely on collection being eager?

Probably not.

Why does it even monomorphize items in the first place?

I tried to make as many tests pass using it.

@michaelwoerister

This comment has been minimized.

Copy link
Contributor

michaelwoerister commented Jan 9, 2019

Since the results of the method calls in the loop are not used, I assume the calls are only there for triggering diagnostics.

  • The inst.def.is_inline(tcx) call does not seem to be needed, since it has no side effects.
  • The codegen_fn_attrs query does some validation. It would, however, work just as well without doing monomorphization. Depending on whether this backend is used in a performance-critical scenario, it would make sense to try and acquire the list of relevant DefIds without running the monomorphization collector. tcx.hir().krate().visit_all_item_likes() should do the trick.

@lqd lqd changed the title codegen-backend: run the collector only once MetadataOnlyCodegenBackend: run the collector only once Jan 9, 2019

@bjorn3

This comment has been minimized.

Copy link
Contributor

bjorn3 commented Jan 9, 2019

Since the results of the method calls in the loop are not used, I assume the calls are only there for triggering diagnostics.

Yes.

Depending on whether this backend is used in a performance-critical scenario

As far as I know it hasn't really been used by anyone (including me). It can be removed if you want.

MetadataOnlyCodegenBackend: remove `is_inline` call
This function has no side effects, and its result is ignored.
@michaelwoerister

This comment has been minimized.

Copy link
Contributor

michaelwoerister commented Jan 14, 2019

OK, let's merge the current version for now. This is an unused component, I don't want to put too much time into it.

Thanks for looking into it, @lqd!

@bors r+ rollup

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 14, 2019

📌 Commit e5318f3 has been approved by michaelwoerister

Centril added a commit to Centril/rust that referenced this pull request Jan 14, 2019

Rollup merge of rust-lang#57418 - lqd:collector_query, r=michaelwoeri…
…ster

MetadataOnlyCodegenBackend: run the collector only once

Use the `collect_and_partition_mono_items` query to avoid calling the collector directly twice.

Fixes rust-lang#57406.

Centril added a commit to Centril/rust that referenced this pull request Jan 14, 2019

Rollup merge of rust-lang#57418 - lqd:collector_query, r=michaelwoeri…
…ster

MetadataOnlyCodegenBackend: run the collector only once

Use the `collect_and_partition_mono_items` query to avoid calling the collector directly twice.

Fixes rust-lang#57406.

Centril added a commit to Centril/rust that referenced this pull request Jan 14, 2019

Rollup merge of rust-lang#57418 - lqd:collector_query, r=michaelwoeri…
…ster

MetadataOnlyCodegenBackend: run the collector only once

Use the `collect_and_partition_mono_items` query to avoid calling the collector directly twice.

Fixes rust-lang#57406.

Centril added a commit to Centril/rust that referenced this pull request Jan 14, 2019

Rollup merge of rust-lang#57418 - lqd:collector_query, r=michaelwoeri…
…ster

MetadataOnlyCodegenBackend: run the collector only once

Use the `collect_and_partition_mono_items` query to avoid calling the collector directly twice.

Fixes rust-lang#57406.

bors added a commit that referenced this pull request Jan 14, 2019

Auto merge of #57592 - Centril:rollup, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #57232 (Parallelize and optimize parts of HIR map creation)
 - #57418 (MetadataOnlyCodegenBackend: run the collector only once)
 - #57465 (Stabilize cfg_target_vendor)
 - #57477 (clarify resolve typo suggestion)
 - #57556 (privacy: Fix private-in-public check for existential types)
 - #57584 (Remove the `connect_timeout_unroutable` test.)

Failed merges:

r? @ghost

@bors bors merged commit e5318f3 into rust-lang:master Jan 14, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@lqd lqd deleted the lqd:collector_query branch Jan 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment