-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
OOM (huge memory usage) during release compilation with include_str of 100MB #70035
Copy link
Copy link
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-compilememIssue: Problems and improvements with respect to memory usage during compilation.Issue: Problems and improvements with respect to memory usage during compilation.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-compilememIssue: Problems and improvements with respect to memory usage during compilation.Issue: Problems and improvements with respect to memory usage during compilation.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Type
Fields
Give feedbackNo fields configured for issues without a type.
When compiling a project of mine, my PC with 32GB of RAM went OOM. I reduced the problem to the following code:
Compiling this code with
/usr/bin/time -v cargo build --releaseshows a maximum resident RAM usage of 16GB if testdata is generated withpython -c "print('foo bar baz qux 1337 42\n' * 4_500_000)" > testdata(103MB). In debug mode, only 1.3GB RAM are used. It doesn't matter if edition is 2018 or not.Here are some different testdata sizes with their compilation memory usage:
'foo bar baz qux 1337 42\n' * 4_500_000'foo bar baz qux 1337 42 ' * 4_500_000'a' * 100*1024*1024'a' * 80*1024*1024'a' * 50*1024*1024'a' * 25*1024*1024'a' * 10*1024*1024'a' * 1*1024*1024If anything in the code is changed, the problem gets slightly better. Here is the RAM usage after some small changes for 100MB (for comparison,
include_strjust with a hello-world requires 670MB):Vecinstead of theHashMap: 2.5GBparse_testdatafunction: 6GBparse_testdatafunction manually: 6GBparse_testdatanot return anything and remove the HashMap from the function: 2.5GB()instead ofvec![0]: 6GBdo_stuff: 672MBMeta
uname -a:Linux 5.5.4-arch1-1-vfio #1 SMP PREEMPT Wed, 19 Feb 2020 15:49:02 +0000 x86_64 GNU/Linux(Archlinux)Tested on (always testing with 100MB):
rustc 1.42.0 (b8cedc004 2020-03-09): 16GBrustc 1.43.0-nightly (45ebd5808 2020-03-15): 16GBrustc 1.41.1 (f3e1a954d 2020-02-24): 16GBrustc 1.41.0 (5e1a79984 2020-01-27): 16GBrustc 1.40.0 (73528e339 2019-12-16): 2.5GBrustc 1.39.0 (4560ea788 2019-11-04): 2.5GBrustc 1.38.0 (625451e37 2019-09-23): 6GBrustc 1.35.0 (3c235d560 2019-05-20): 6GBrustc 1.34.0 (91856ed52 2019-04-10): 6GBrustc 1.32.0 (9fda7c223 2019-01-16): 8GBrustc 1.30.0 (da5f414c2 2018-10-24): 5GB