Skip to content

Commit f8289ee

Browse files
Merge pull request #10716 from dotty-staging/cpu-limit-2
CI: Better way of limiting CPU usage
2 parents 265a279 + 6ed4afc commit f8289ee

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

.github/workflows/ci.yaml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,26 @@ on:
99
env:
1010
DOTTY_CI_RUN: true
1111

12+
# In this file, we set `--cpu-shares 4096` on every job. This might seem useless
13+
# since it means that every container has the same weight which should be
14+
# equivalent to doing nothing, but it turns out that OpenJDK computes
15+
# `Runtime.getRuntime.availableProcessors` by dividing the cpu-shares value if
16+
# it exists by 1024 (cf
17+
# http://mail.openjdk.java.net/pipermail/hotspot-dev/2019-January/036087.html),
18+
# so this means that we effectively run every job with 4 cores. This is much
19+
# nicer than setting `--cpus 4` because the latter enforces CPU quotas and ends
20+
# up slowing our jobs more than needed. It's equivalent to running the JVM with
21+
# `-XX:ActiveProcessorCount=4`, but since our tests can spawn new JVM in many
22+
# places, it would be very hard to ensure that this option is always passed to
23+
# `java` (we could use the `_JAVA_OPTIONS` environment variable, but this prints
24+
# text on stderr and so can break tests which check the output of a program).
25+
1226
jobs:
1327
test_non_bootstrapped:
1428
runs-on: [self-hosted, Linux]
1529
container:
1630
image: lampepfl/dotty:2020-11-19
17-
options: --cpus=4
31+
options: --cpu-shares 4096
1832
volumes:
1933
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
2034
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
@@ -54,7 +68,7 @@ jobs:
5468
runs-on: [self-hosted, Linux]
5569
container:
5670
image: lampepfl/dotty:2020-11-19
57-
options: --cpus=4
71+
options: --cpu-shares 4096
5872
volumes:
5973
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
6074
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
@@ -149,7 +163,7 @@ jobs:
149163
runs-on: [self-hosted, Linux]
150164
container:
151165
image: lampepfl/dotty:2020-11-19
152-
options: --cpus=4
166+
options: --cpu-shares 4096
153167
volumes:
154168
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
155169
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
@@ -185,7 +199,7 @@ jobs:
185199
runs-on: [self-hosted, Linux]
186200
container:
187201
image: lampepfl/dotty:2020-11-19
188-
options: --cpus=4
202+
options: --cpu-shares 4096
189203
volumes:
190204
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
191205
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
@@ -221,7 +235,7 @@ jobs:
221235
runs-on: [self-hosted, Linux]
222236
container:
223237
image: lampepfl/dotty:2020-11-19
224-
options: --cpus=4
238+
options: --cpu-shares 4096
225239
volumes:
226240
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
227241
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
@@ -257,7 +271,7 @@ jobs:
257271
runs-on: [self-hosted, Linux]
258272
container:
259273
image: lampepfl/dotty:2020-11-19
260-
options: --cpus=4
274+
options: --cpu-shares 4096
261275
volumes:
262276
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
263277
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
@@ -300,7 +314,7 @@ jobs:
300314
runs-on: [self-hosted, Linux]
301315
container:
302316
image: lampepfl/dotty:2020-11-19
303-
options: --cpus=4
317+
options: --cpu-shares 4096
304318
volumes:
305319
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
306320
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
@@ -335,7 +349,7 @@ jobs:
335349
runs-on: [self-hosted, Linux]
336350
container:
337351
image: lampepfl/dotty:2020-11-19
338-
options: --cpus=4
352+
options: --cpu-shares 4096
339353
volumes:
340354
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
341355
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
@@ -377,7 +391,7 @@ jobs:
377391
runs-on: [self-hosted, Linux]
378392
container:
379393
image: lampepfl/dotty:2020-11-19
380-
options: --cpus=4
394+
options: --cpu-shares 4096
381395
volumes:
382396
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
383397
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
@@ -460,7 +474,7 @@ jobs:
460474
runs-on: [self-hosted, Linux]
461475
container:
462476
image: lampepfl/dotty:2020-11-19
463-
options: --cpus=4
477+
options: --cpu-shares 4096
464478
volumes:
465479
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
466480
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
@@ -505,6 +519,7 @@ jobs:
505519
runs-on: [self-hosted, Linux]
506520
container:
507521
image: lampepfl/dotty:2020-11-19
522+
options: --cpu-shares 4096
508523
volumes:
509524
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
510525
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache

0 commit comments

Comments
 (0)