File 0552-asn1-compiler-Avoid-running-out-of-memory-on-Windows.patch of Package erlang

From 8cb8d3d5d6ec15c4e8f27366b72baffde39485f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Wed, 26 Oct 2022 09:34:41 +0200
Subject: [PATCH 2/4] asn1, compiler: Avoid running out of memory on Windows

If a test machine has many CPU cores but is running the 32-bit
version of Windows, some of the memory-intensive tests such a
compile_SUITE:core_roundtrip/1 can easily run out of memory
if all cores are used. Avoid this by limiting the number of
parallel processes started by asn1_test_lib:p_run/2 and
test_lib:p_run/2.
---
 lib/asn1/test/asn1_test_lib.erl | 9 ++++++++-
 lib/compiler/test/test_lib.erl  | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/lib/asn1/test/asn1_test_lib.erl b/lib/asn1/test/asn1_test_lib.erl
index 0a331d0dd0..d421c29dd3 100644
--- a/lib/asn1/test/asn1_test_lib.erl
+++ b/lib/asn1/test/asn1_test_lib.erl
@@ -306,7 +306,14 @@ ber_get_len(<<1:1,Octets:7,T0/binary>>) ->
 %%  Will fail the test case if there were any errors.
 
 p_run(Test, List) ->
-    S = erlang:system_info(schedulers),
+    %% Limit the number of parallel processes to avoid running out of
+    %% memory.
+    S = case {erlang:system_info(schedulers),erlang:system_info(wordsize)} of
+            {S0,4} ->
+                min(S0, 2);
+            {S0,_} ->
+                min(S0, 8)
+        end,
     N = case test_server:is_cover() of
 	    false ->
 		S + 1;
diff --git a/lib/compiler/test/test_lib.erl b/lib/compiler/test/test_lib.erl
index 7182dd6555..0328ed9f26 100644
--- a/lib/compiler/test/test_lib.erl
+++ b/lib/compiler/test/test_lib.erl
@@ -157,7 +157,14 @@ highest_opcode(Beam) ->
 %%  Will fail the test case if there were any errors.
 
 p_run(Test, List) ->
-    S = erlang:system_info(schedulers),
+    %% Limit the number of parallel processes to avoid running out of
+    %% memory.
+    S = case {erlang:system_info(schedulers),erlang:system_info(wordsize)} of
+            {S0,4} ->
+                min(S0, 2);
+            {S0,8} ->
+                min(S0, 8)
+        end,
     N = S + 1,
     io:format("p_run: ~p parallel processes\n", [N]),
     p_run_loop(Test, List, N, [], 0, 0).
-- 
2.35.3

openSUSE Build Service is sponsored by