Skip to content

Conversation

kkimurak
Copy link
Contributor

This PR just adds image ENV NO_SOURCEMAPS=true.

As I reported in #2860 (#2860 (comment)), we can set webpack configuration devtool to false by setting environment variable NO_SOURCEMAP=true. This will significantly reduce the time taken by the rake task gitlab:assets:compile, which took up a large portion of the image build (total build time have been improved from 30min to 20min on my env).

It also reduce image size : v18.1.2, 4.31GB -> 3.86GB.

In webpack documentation, it is recommended to set devtool to be disabled on production with maximum performance.

devtool performance production quality comment
(none) build: fastest
rebuild: fastest
yes bundle Recommended choice for production builds with maximum performance.

Official gitlab image gitlab/gitlab-ce and gitlab/gitlab-ee also does not ship with sourcemaps (see #2860 (comment)).

Since I have not yet been able to verify how much each factor, such as CPU, memory, or disk I/O, affects the speed improvement, I would like to check the build time of this pull request to see how much the speed has improved in CI.

@kkimurak
Copy link
Contributor Author

Build job 8731 completed in 26min 54sec. Compared to 8696 (18.1.2 release pull request #3137) tooks 39m 44s, reduced about 13 minutes.

@kkimurak
Copy link
Contributor Author

kkimurak commented Jul 15, 2025

Well, at this point I'm not sure if this pull request is the right direction.

It definitely reduces build times and image size, by not compiling sourcemaps.

I thought I understood how much of an impact it would have, but after reviewing the upstream discussion I'm not sure again.


I have noticed that official images gitlab/gitlab-ce and gitlab/gitlab-ee does not ship with uncompressed .map files but with compressed map files (*.gz). Uncompressed files are just removed on image built, since 12.10.0 (introduced by gitlab.com/gitlab-org/omnibus-gitlab!3592).
CNG (Cloud Native container images per component of GitLab) takes similar approach. See gitlab.com/gitlab-org/build/CNG!613.

This means that assets need to be compiled once, which takes so long that I initially thought I would disable it, thus making this pull request pointless.

I found evidence that NO_SOURCEMAPS was set in image builds for low memory enviornment such as Raspberry Pi around version v11.0.2, but this setting is no longer present - I was unable to determine whether the setting has been removed or is being managed in a different way. See gitlab.com/gitlab-org/omnibus-gitlab!2606

GitLab.com seems to be providing source maps (via CDN) to avoid confusing users seeing a lot of 404 on console. See discussions for example: gitlab.com/gitoab-org/gitlab#212240.

@kkimurak
Copy link
Contributor Author

GitLab.com seems to be providing source maps (via CDN) to avoid confusing users seeing a lot of 404 on console. See discussions for example: gitlab.com/gitoab-org/gitlab#212240.

I realized no link to sourcemap are inserted in minified sources (.js, .css) if I set NO_SOURCEMAPS=true (disabling devtool in webpack config). Above discussion seems to be that there was an issue with CDN to deliver compressed files as sourcemap.
If this is the case, then this won't affect anyone other than developers using sameersbn/gitlab to debug issues in the gitlab frontend.

@kkimurak kkimurak force-pushed the do-not-compile-sourcemap-for-gitlab-assets branch 2 times, most recently from 51ff63c to 5e571b7 Compare August 21, 2025 09:24
30min -> 20min on my old PC, 20min -> 10min on my new PC
@kkimurak kkimurak force-pushed the do-not-compile-sourcemap-for-gitlab-assets branch from 5e571b7 to 8076ab2 Compare September 2, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant