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

Added detail to codegen section #1216

Closed
wants to merge 6 commits into from

Conversation

Sl1mb0
Copy link
Contributor

@Sl1mb0 Sl1mb0 commented Sep 21, 2021

This provides more in-depth descriptions of the parallelism occurring during codegen. There are probably a few things I got wrong conceptually, so don't hesitate to point them out :)

thread to generate work for them. If `parallel_compiler` _is_ true, the LLVM queue is
loaded in parallel.

At the end, the linker is ran and combines all the compiled codegen units together into one binary.
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
At the end, the linker is ran and combines all the compiled codegen units together into one binary.
At the end, the linker is run and combines all the compiled codegen units together into one binary.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
At the end, the linker is ran and combines all the compiled codegen units together into one binary.
At the end, the compiled codegen units together into the final artifact. For binary executable results this is done by a linker.

Executable binary is not the only kind of the output we have. rlibs, sos and os are some of the others.

Copy link
Member

Choose a reason for hiding this comment

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

@nagisa I think your suggestion may be missing the words "are combined together" or similar.

@camelid camelid added the waiting-on-review This PR is waiting for a reviewer to verify its content label Oct 12, 2021
@camelid
Copy link
Member

camelid commented Oct 12, 2021

@nagisa Could you give this a review? Feel free to reassign by the way :)

Once the partitions have been sorted, the smallest and largest halves are iterated over separately.
Their elements are paired and stored in a `Vec` so that the largest
and smallest partitions are first and second, the second largest and smallest are
third and fourth, and so on. These partitions are then translated into LLVM-IR.

Choose a reason for hiding this comment

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

I think it is misleading to mention LLVM IR explicitly, especially now that there are 5+ rustc codegens for all kinds of IRs. It should mention that a codegen backend is invoked to translate the cgu to its particular IR. Especially because you dont mention cg_llvm, only cg_ssa, and cg_ssa does not do any llvm things.

Copy link
Member

Choose a reason for hiding this comment

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

I also don't think its all that important to talk about the particularities of how the order of the CUs to translate is established. It suffices to say, I feel, that the compiler partition and order the CUs in an effort to [... whatever the goals are at the given time...]

the largest partitions would be in memory at the same time; increasing memory consumption and
impacting overall performance.

Once the partitions have been organized they must be translated into LLVM-IR, where they are

Choose a reason for hiding this comment

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

same thing as above

- A `rustc` version of an [OwningRef][OwningRef]

First, we collect and partition the [monomorphized][monomorphization] version of the program
that has been compiled. The individual partitions are then sorted from largest to smallest.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
that has been compiled. The individual partitions are then sorted from largest to smallest.
that is being compiled. The individual partitions are then sorted from largest to smallest.

Once the partitions have been sorted, the smallest and largest halves are iterated over separately.
Their elements are paired and stored in a `Vec` so that the largest
and smallest partitions are first and second, the second largest and smallest are
third and fourth, and so on. These partitions are then translated into LLVM-IR.
Copy link
Member

Choose a reason for hiding this comment

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

I also don't think its all that important to talk about the particularities of how the order of the CUs to translate is established. It suffices to say, I feel, that the compiler partition and order the CUs in an effort to [... whatever the goals are at the given time...]

thread to generate work for them. If `parallel_compiler` _is_ true, the LLVM queue is
loaded in parallel.

At the end, the linker is ran and combines all the compiled codegen units together into one binary.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
At the end, the linker is ran and combines all the compiled codegen units together into one binary.
At the end, the compiled codegen units together into the final artifact. For binary executable results this is done by a linker.

Executable binary is not the only kind of the output we have. rlibs, sos and os are some of the others.

@camelid camelid added waiting-on-author This PR is waiting for additional action by the OP and removed waiting-on-review This PR is waiting for a reviewer to verify its content labels Oct 17, 2021
@JohnTitor
Copy link
Member

@Sl1mb0 Triage ping, could you address the review comments above?

@JohnTitor
Copy link
Member

I'm going to close this as inactive but feel free to re-open another PR or pick up their work if anyone is interested in continuing the work, thanks for contributing!

@JohnTitor JohnTitor closed this Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-author This PR is waiting for additional action by the OP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants