Webpack 5 upgrade - investigate OOM errors

From initial investigation, webpack 5 requires more memory than the currently configured heap limit.

It could possibly be related to using worker threads as opposed to processes, but needs investigation.

Edit: Findings

tl;dr; Webpack 5's minimum memory needs are higher. This can be mitigated with esbuild for minification.

  1. Both webpack 4 and webpack 5 cannot build on a docker container with 5gb of memory
  2. Webpack 4 can build on a container with 7gb of memory
  3. Webpack 5 (using esbuild for minification) can also build on a container with 7gb of memory
  4. Currently, Webpack 5 (without esbuild) cannot build on a container with 7gb of memory.

Suggested minimum needs:

  • Webpack 4 - 7gb
  • Webpack 5 - 8gb

CI Runners for gitlab-org are configured with a google machine type of n2d-standard-2, which have 2cpus and 8gb of RAM. This should be enough to support a migration to Webpack 5 with or without esbuild.

using psrecord

Current benchmarking approach using psrecord

needs

  1. asdf install python 3.9.0
  2. asdf global python 3.9.0
  3. pip install psrecord
  4. pip install matplotlib
  5. asdf reshim python

running a benchmark using webpack 4

  1. git clone git@gitlab.com:gitlab-org/gitlab.git gitlab-webpack-4 && cd gitlab-webpack-4
  2. yarn install
  3. psrecord "yarn <webpack|webpack-prod>" --plot result.png --log result.log --include-children

running a benchmark using webpack 5

  1. git clone git@gitlab.com:gitlab-org/gitlab.git gitlab-webpack-5 && cd gitlab-webpack-5
  2. git checkout qa/webpack_records
  3. yarn install
  4. psrecord "yarn <webpack|webpack-prod>" --plot result.png --log result.log --include-children
Edited by Sean Gregory