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 a note about hardware requirements for compiling on Linux #70658

Merged

Conversation

art-divin
Copy link
Contributor

@art-divin art-divin commented Dec 31, 2023

When I was setting up a Linux VM environment for debugging Swift compiler crash, I faced a number of issues due to low disk space (update-checkout would hang before starting concurrent checkouts) and due to low RAM size (linker would start failing when linking symbols for bin/clang-17 and other binaries).

This PR adds a note about the minimal RAM requirements, and updates the recommended minimum available disk space.

My findings for when running a Linux VM and compiling the compiler are as follows:

  1. 8 GB of RAM with --release-debuginfo flag
  2. 32 GB of RAM with --debug flag
  3. 150 GB of disk space

@art-divin art-divin changed the title Added a note about Linux inside of a VM hardware requirements Added a note about hardware requirements for compiling on Linux Jan 4, 2024
Copy link
Contributor

@finagolfin finagolfin left a comment

Choose a reason for hiding this comment

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

Other than nit on phrasing, seems worthwhile.

docs/HowToGuides/GettingStarted.md Outdated Show resolved Hide resolved
@art-divin art-divin force-pushed the improve-getting-started-linux-vm branch 2 times, most recently from 8792e38 to 3427ace Compare January 4, 2024 17:02
@finagolfin
Copy link
Contributor

Ping @AnthonyLatsis, what do you think?

@art-divin art-divin force-pushed the improve-getting-started-linux-vm branch from 3427ace to 307d002 Compare January 10, 2024 15:46
Comment on lines 193 to 195
> **Note**
> When building on Linux, make sure to have at least 8 GB of RAM when using flag `--release-debuginfo` and 32 GB of RAM when using flag `--debug-swift`, plus 150 GB of disk space available.

Copy link
Collaborator

Choose a reason for hiding this comment

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

  • I think this should go under "System Requirements". Perhaps we should update the default disk space requirement to 100GB too.
  • What’s taking up 150GB on Linux? The entire checkout plus a --release-debuginfo --debug-swift build is only about 70GB for me on macOS.
  • How much RAM was not enough to pull through a --debug-swift build, 16GB?

Copy link
Contributor Author

@art-divin art-divin Jan 12, 2024

Choose a reason for hiding this comment

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

I think this should go under "System Requirements". Perhaps we should update the default disk space requirement to 100GB too.

Amazing, I did not even notice this section! Surely, updated 🤝

What’s taking up 150GB on Linux? The entire checkout plus a --release-debuginfo --debug-swift build is only about 70GB for me on macOS.

--debug-swift took 78 GB of disk space, plus according to Development Tips it is recommended to set sccache SCCACHE_CACHE_SIZE environment variable to 50 GB. Then, system size is about 19 GB.
I've ran out of space mostly because I am still unable to compile with --debug-swift --debug-foundation flags, and have to resort to --release-debuginfo -T --debug-swift-stdlib to make some progress in crash investigation. Nonetheless, 150 GB is enough to avoid running into a problem with low disk space in the middle of LLVM compilation, for example.

Folders Size
image image

How much RAM was not enough to pull through a --debug-swift build, 16GB?

Answering your question, 4 GB was my initial VM setup, and I wasted 3 days figuring out why linking was failing, discovered the fact by accident. So my intention with this PR is to let others know how to avoid redundant investigations and work.

Even with 32 GB of RAM, linking of clang-17 binary fails every single time in a VM. On hardware Linux, it'd be better I presume; however, after 2-3 tries I am able to link largest binaries. On the other hand, if to limit concurrent tasks with -j 5, for instance, failures are more rare, but still occur for the same reason, not enough RAM available.

@art-divin art-divin force-pushed the improve-getting-started-linux-vm branch from 307d002 to b5b0f96 Compare January 12, 2024 19:48
Copy link
Collaborator

@AnthonyLatsis AnthonyLatsis left a comment

Choose a reason for hiding this comment

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

Thank you! Just one more suggestion.

Comment on lines 58 to 62
5. RAM:
On Linux, it is recommended to have at least 8 GB of RAM when compiling
with the `--release-debuginfo` build flag and at least 16 GB of RAM available
when compiling with the `--debug-swift` build flag.
For the best experience, 32 GB of RAM is recommended.
Copy link
Collaborator

@AnthonyLatsis AnthonyLatsis Jan 13, 2024

Choose a reason for hiding this comment

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

Let us provide a reasonable platform-agnostic requirement and stress on emulators at the end. This way, we don’t have to special-case Linux or increase cognitive load with build-script flags before we even start talking about them.

Suggested change
5. RAM:
On Linux, it is recommended to have at least 8 GB of RAM when compiling
with the `--release-debuginfo` build flag and at least 16 GB of RAM available
when compiling with the `--debug-swift` build flag.
For the best experience, 32 GB of RAM is recommended.
5. RAM:
It is recommended to have at least 8 GB for building a toolchain and 16 GB
for development. When building for development on a virtual machine or
emulator, you might need more than 32 GB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very nice rephrasing, thank you for your input 🤝

commit bcc59744b7da00395708f41984ee2be70924cb6c
Author: Ruslan Alikhamov <r.alikhamov@gmail.com>
Date:   Sat Jan 13 15:28:42 2024 +0400

    applied suggested phrasing

commit b5b0f96
Author: Ruslan Alikhamov <r.alikhamov@gmail.com>
Date:   Fri Jan 12 23:48:12 2024 +0400

    Added a note about hardware requirements for compiling on Linux

    commit 863c1d98dd8c3c3e67610fe9ea9ac00e161d687a
    Author: Ruslan Alikhamov <r.alikhamov@gmail.com>
    Date:   Fri Jan 12 23:47:19 2024 +0400

        Moved note to Requirements section

    commit 307d002
    Author: Ruslan Alikhamov <r.alikhamov@gmail.com>
    Date:   Wed Jan 10 19:45:54 2024 +0400

        Added a note about hardware requirements for compiling on Linux

        commit 943ccc2726aa2f8850f38670b848304acb3359aa
        Author: Ruslan Alikhamov <r.alikhamov@gmail.com>
        Date:   Wed Jan 10 19:45:13 2024 +0400

            Replaced 'and' with 'plus' to ease comprehension

        commit 3427ace
        Author: Ruslan Alikhamov <r.alikhamov@gmail.com>
        Date:   Thu Jan 4 21:02:22 2024 +0400

            Added a note about hardware requirements for compiling on Linux

            commit 49bafe9
            Author: Ruslan Alikhamov <r.alikhamov@gmail.com>
            Date:   Thu Jan 4 20:49:35 2024 +0400

                Added "of RAM" to each reference

            commit 9dc879c
            Author: Ruslan Alikhamov <r.alikhamov@gmail.com>
            Date:   Thu Jan 4 14:13:20 2024 +0400

                Updated text according to comment, removed mention of VM for Linux

            commit b652195
            Author: Ruslan Alikhamov <r.alikhamov@gmail.com>
            Date:   Wed Jan 3 00:06:18 2024 +0400

                Added more information about different RAM requirements

            commit 2aa1be0
            Author: Ruslan Alikhamov <r.alikhamov@gmail.com>
            Date:   Mon Jan 1 03:19:22 2024 +0400

                Added a note about Linux inside of a VM hardware requirements
@art-divin art-divin force-pushed the improve-getting-started-linux-vm branch from b5b0f96 to fd3557b Compare January 13, 2024 11:29
@AnthonyLatsis
Copy link
Collaborator

@xedin It’s your call now!

@art-divin
Copy link
Contributor Author

Thank you very much for your approvals 🤝

I wonder what would be the next step, shall we run CI for such change, or just merge? How to proceed, I'd appreciate any hint 👍🏻

@AnthonyLatsis
Copy link
Collaborator

AnthonyLatsis commented Jan 23, 2024

I wonder what would be the next step, shall we run CI for such change, or just merge?

We’re waiting for a code owner to also approve your changes.

ping @xedin

@AnthonyLatsis
Copy link
Collaborator

@xedin ping 🙂

@AnthonyLatsis
Copy link
Collaborator

@swift-ci please smoke test

@AnthonyLatsis
Copy link
Collaborator

Thanks!

@AnthonyLatsis AnthonyLatsis merged commit 5dac5e2 into swiftlang:main Feb 13, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants