An open source design system that's fully customizable and agent ready
TypeScript
ci: the WebKit interaction lane caps llvmpipe's threads at the job's CPU quota (#9245)
Cindy Zhang9061bd7f805e
diff --git a/.github/scripts/ci-interaction-webkit.test.mjs b/.github/scripts/ci-interaction-webkit.test.mjsindex 20982174e6..42a81fd271 100644--- a/.github/scripts/ci-interaction-webkit.test.mjs+++ b/.github/scripts/ci-interaction-webkit.test.mjs@@ -116,6 +116,41 @@ describe('WebKit interaction proof routing', () => {expect(run).not.toContain('--project chromium');});+ it("caps llvmpipe's threads at the job's cgroup CPU quota before Playwright runs", async () => {+ const run = step(webkit, 'Run WebKit interaction proofs').run;+ const setup = run.slice(0, run.indexOf('pnpm exec playwright test'));+ expect(setup).toContain('export LP_NUM_THREADS');+ // Run the setup against a quota file: a 2-CPU quota caps a 64-CPU view,+ // no quota keeps nproc, and the quota never raises the count.+ const {execFileSync} = await import('node:child_process');+ const fs = await import('node:fs');+ const os = await import('node:os');+ const path = await import('node:path');+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'lp-threads-'));+ const threads = (cpuMax, cpus) => {+ const quota = path.join(dir, 'cpu.max');+ if (cpuMax == null) fs.rmSync(quota, {force: true});+ else fs.writeFileSync(quota, `${cpuMax}\n`);+ const script = `nproc() { echo ${cpus}; }\n${setup.replaceAll(+ '/sys/fs/cgroup/cpu.max',+ quota,+ )}\necho "$LP_NUM_THREADS"`;+ return execFileSync('bash', ['-c', script], {encoding: 'utf8'})+ .trim()+ .split('\n')+ .at(-1);+ };+ try {+ expect(threads('200000 100000', 64)).toBe('2');+ expect(threads('150000 100000', 64)).toBe('2');+ expect(threads('max 100000', 64)).toBe('64');+ expect(threads(null, 4)).toBe('4');+ expect(threads('800000 100000', 4)).toBe('4');+ } finally {+ fs.rmSync(dir, {recursive: true, force: true});+ }+ });+it('runs only the specs whose code its scope covers', () => {const run = step(webkit, 'Run WebKit interaction proofs').run;const targets = [diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 88f5897657..772d440bbd 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -2041,9 +2041,27 @@ jobs:if: steps.scope.outputs.applies == 'true'run: pnpm install --frozen-lockfile && npx playwright install --with-deps webkit+ # WebKit renders through Mesa's llvmpipe, which sizes its thread pool+ # from the CPUs the process may run on. A container's CPU quota is not+ # that mask, so a runner that shows the host's CPUs oversubscribes the+ # job's share. Cap llvmpipe's threads at the cgroup quota when one is+ # set (the job's share, rounded up); without a quota the count stays+ # nproc, llvmpipe's own default.- name: Run WebKit interaction proofsif: steps.scope.outputs.applies == 'true'run: |+ LP_NUM_THREADS="$(nproc)"+ if [ -r /sys/fs/cgroup/cpu.max ]; then+ read -r quota period < /sys/fs/cgroup/cpu.max+ if [ "$quota" != max ]; then+ share=$(( (quota + period - 1) / period ))+ if [ "$share" -lt "$LP_NUM_THREADS" ]; then+ LP_NUM_THREADS="$share"+ fi+ fi+ fi+ export LP_NUM_THREADS+ echo "llvmpipe threads: $LP_NUM_THREADS"pnpm exec playwright test \packages/core/src/gestures/ \packages/core/src/motion/__tests__/animatedLayout.interaction \