Skip to content

Commit 1d4646d

Browse files
authored
Speed up Docusaurus build (#146)
* Speed up Docusaurus build with Rspack, image compression, and CI caching - Add @docusaurus/faster for Rspack bundler, SWC transpilation/minification, Lightning CSS, MDX cross-compiler cache, and multi-threaded SSG - Limit dev server to current version only for faster local development - Remove babel.config.js (replaced by SWC) - Add Docusaurus build cache step in CI workflow - Upgrade Node from 20 to 24 in CI - Compress 138 large PNG images with pngquant (65-80% quality) * Compress PNG images over 100KB with pngquant 330 additional images compressed (quality 65-80%, skip-if-larger). Reduces repository size and speeds up checkout, CI, and deployment. * Pin actions/cache to full commit SHA Required by org policy that all actions must be pinned to a full-length commit SHA. * Trigger CI * Reduce Node heap to 4 GB to prevent OOM on CI runners Rspack (which replaced webpack) runs as native Rust code outside the Node heap. With 6 GB allocated to Node, peak memory reached 8.3 GB total (Node + Rspack native), exceeding the 7 GB runner limit and causing the Linux OOM killer to terminate the build. Setting the heap to 4 GB leaves ~3 GB for Rspack and the OS. * Add swap space to CI runner to prevent OOM kills The Rspack build peaks at ~8 GB, exceeding the 7 GB runner limit. Adding 10 GB swap prevents the Linux OOM killer from terminating the build process. * Fix swap setup: resize existing swapfile instead of creating new one GitHub runners already have a 4 GB /swapfile in use. Disable it first, then recreate at 14 GB to give enough headroom for the Rspack build. * Restore Node heap to 6 GB now that swap prevents OOM kills With 14 GB swap as safety net, the 6 GB heap allows V8 to GC less aggressively, improving build performance. Brief memory peaks above 7 GB will use swap instead of crashing.
1 parent 28d9609 commit 1d4646d

473 files changed

Lines changed: 684 additions & 7 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci_cd.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,48 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
env:
18-
# Hosted GitHub runners have 7 GB of memory available, let's use 6 GB
18+
# Hosted GitHub runners have 7 GB of memory available, swap handles brief peaks above this
1919
NODE_OPTIONS: --max-old-space-size=6144
2020

2121
jobs:
2222
build:
2323
name: Build
2424
runs-on: ubuntu-latest
2525
steps:
26+
- name: Add swap space
27+
run: |
28+
# Resize existing swap from default 4 GB to 14 GB
29+
sudo swapoff /swapfile || true
30+
sudo rm -f /swapfile
31+
sudo fallocate -l 14G /swapfile
32+
sudo chmod 600 /swapfile
33+
sudo mkswap /swapfile
34+
sudo swapon /swapfile
35+
free -h
36+
2637
- name: Checkout
2738
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
2839

2940
- name: Setup Node
3041
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
3142
with:
32-
node-version: '20'
43+
node-version: '24'
3344
cache: 'yarn'
3445
cache-dependency-path: yarn.lock
3546

3647
- name: Install dependencies
3748
run: yarn install --immutable
3849

50+
- name: Cache Docusaurus build
51+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
52+
with:
53+
path: |
54+
.docusaurus
55+
node_modules/.cache
56+
key: docusaurus-${{ runner.os }}-${{ hashFiles('yarn.lock', 'docusaurus.config.ts', 'versions.json') }}
57+
restore-keys: |
58+
docusaurus-${{ runner.os }}-
59+
3960
- name: Build
4061
run: yarn build
4162

babel.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.
-81.3 KB
-85.6 KB
-188 KB
-110 KB
-148 KB
-331 KB
-148 KB
-194 KB

0 commit comments

Comments
 (0)