-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the FBPCF and dependent builds to use multi-threaded builds (#474
) Summary: Pull Request resolved: #474 # Context This change is intended to help speed up the builds for FBPCF and all the dependent images. Right now we are using a C4.4xlarge instance for building the images, but we never use anywhere near the CPU or Memory limits for an instance that large. This change allows us to take more advantage of that instance size and improve our build times. Some examples when building with the FBPCS machine are that we were only using about 6% CPU for a build and this change increased it to ~25% and reduced the build time from ~40 minutes to ~19 minutes. https://pxl.cl/2qpD2 (7566956) https://pxl.cl/2qpD1 # This Diff This diff updates the FBPCF builds to take advantage of the same build features. Right now builds are taking ~ 55 mintues. After the change, they are taking less than 30 minutes. ## Before the change: ``` build binaries completed successfully 0.04s user 0.05s system 0% cpu 56:40.53 total ``` Logs: https://www.internalfb.com/intern/paste/P603909791/ ##After the change: ``` build binaries completed successfully 0.01s user 0.04s system 0% cpu 29:26.80 total ``` Logs: https://www.internalfb.com/intern/paste/P603946390/ Reviewed By: marksliva Differential Revision: D42626641 fbshipit-source-id: 94b27b861a1c0652e4409fc61b15a1dffd7d9576
- Loading branch information
1 parent
20d6beb
commit 78b356f
Showing
5 changed files
with
40 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
BYTES_PER_MEGABYTE=1000000 | ||
|
||
# We need up to 2000 MB (less than 2GB) per thread. | ||
MAX_THREAD_MEMORY_IN_BYTES=$((2000 * BYTES_PER_MEGABYTE)) | ||
|
||
# The functionality below calculates the number of bytes of memory available by getting the number | ||
# Of physical pages available, multiplying it by the page size (in bytes) and dividing that by the | ||
# number of bytes per thread that we want available to give us the maximum number of threads | ||
MAX_THREADS=$(($(getconf _PHYS_PAGES) * $(getconf PAGE_SIZE) / MAX_THREAD_MEMORY_IN_BYTES)) | ||
|
||
# Get the number of possible threads by pulling the online processors | ||
EFFECTIVE_THREADS=$(getconf _NPROCESSORS_ONLN) | ||
|
||
# Use the lesser of the maximum allowed threads by memory or available processors | ||
export MAKE_JOBS=$((MAX_THREADS < EFFECTIVE_THREADS ? MAX_THREADS : EFFECTIVE_THREADS)) | ||
|
||
# Set the maximum load average on the CPU as 9/10ths of the available cores | ||
# This ensures that we don't saturate the CPU with processes that are greater | ||
# than the cores available | ||
export MAKE_MAX_LOAD=$((EFFECTIVE_THREADS * 9 / 10)) |