You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When compiling large array literals in a Linux environment, Swift uses an extremely large amount of memory. For example, memory usage exceeds 500MB when compiling a 1000 element array literal composed of simple structs. If the array is declared as an existential, memory usage balloons to 2GB.
Steps To Reproduce
Steps to reproduce the behavior:
Watching the memory usage via docker stats is definitely not ideal, but I'm not familiar with a better approach to extract peak memory usage or diagnostics from the Swift compiler. I'm definitely open to suggestions here. When collecting the observed peak usage numbers, the swift build command was run multiple times in a row and the maximum number observed in docker stats was recorded.
Expected behavior
Large array literals are able to be compiled with a much smaller amount of memory than currently observed. At runtime these arrays are significantly less than 1MB, yet take many times that amount to compile.
Environment (please fill out the following information)
OS: Ubuntu 20.04
Swift: Nightly toolchain (August 10 at time of filing)
The issue could be reproduced on MacOS as well. Besides the memory consumption, the running time also depends on # of elements. Here is the profiler trace for LargeExistentialArray.swift:
LargeObjectArray.swift has the peak memory consumption / time also in constraint solver.
Describe the bug
When compiling large array literals in a Linux environment, Swift uses an extremely large amount of memory. For example, memory usage exceeds 500MB when compiling a 1000 element array literal composed of simple structs. If the array is declared as an existential, memory usage balloons to 2GB.
Steps To Reproduce
Steps to reproduce the behavior:
Watching the memory usage via
docker stats
is definitely not ideal, but I'm not familiar with a better approach to extract peak memory usage or diagnostics from the Swift compiler. I'm definitely open to suggestions here. When collecting the observed peak usage numbers, theswift build
command was run multiple times in a row and the maximum number observed indocker stats
was recorded.Expected behavior
Large array literals are able to be compiled with a much smaller amount of memory than currently observed. At runtime these arrays are significantly less than 1MB, yet take many times that amount to compile.
Environment (please fill out the following information)
Additional context
This may be related to #58380
The text was updated successfully, but these errors were encountered: