moby: Facing high CPU and memory after upgrade to 28.2.0 Buildkit GC ON

Not sure if this is the right place to post this.

Description

Hello, there.

I am facing a high CPU and memory consumption after upgrading docker from 28.1.1-1 to 28.2.0-1 on Arch Linux (linux 6.12.31-1-lts) at the date of 2025-06-02.

Yesterday, I made a upgrade using yay (yay v12.5.0 - libalpm v15.0.0)

[2025-06-01T13:22:47-0300] [ALPM] upgraded docker (1:28.1.1-1 -> 1:28.2.0-1)
[2025-06-01T13:22:47-0300] [ALPM] upgraded docker-buildx (0.23.0-1 -> 0.24.0-1)
[2025-06-01T13:22:47-0300] [ALPM] upgraded docker-compose (2.36.1-1 -> 2.36.2-1)

After stopping docker.socket and docker.service, the memory was released and I could confirm the issue was the docker upgrade. I made a downgrade to 28.1.1 and restarted docker and everything is fine now.

I did a second test upgrading docker again and restarting and I saw the high memory and CPU again.

Here is a picture of htop when opening only the terminal and with docker 28.2.0 running:

Image

And here is a picture after the downgrade of docker to 28.1.1:

Image

Reproduce

Install docker version 28.2.0 on Arch Linux (linux 6.12.31-1-lts) with yay and inspect memory/CPU with top/htop.

Expected behavior

Docker should run smoothly, as were with version 28.1.1

docker version

Client:
 Version:           28.2.0
 API version:       1.50
 Go version:        go1.24.3
 Git commit:        879ac3f88f
 Built:             Sun Jun  1 13:32:57 2025
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          28.2.0
  API version:      1.50 (minimum version 1.24)
  Go version:       go1.24.3
  Git commit:       0e2cc22d36
  Built:            Sun Jun  1 13:32:57 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v2.1.1
  GitCommit:        cb1076646aa3740577fafbf3d914198b7fe8e3f7.m
 runc:
  Version:          1.3.0
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    28.2.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  0.24.0
    Path:     /usr/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.36.2
    Path:     /usr/lib/docker/cli-plugins/docker-compose

Server:
 Containers: 6
  Running: 0
  Paused: 0
  Stopped: 6
 Images: 197
 Server Version: 28.2.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: cb1076646aa3740577fafbf3d914198b7fe8e3f7.m
 runc version: 
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.12.31-1-lts
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 7.579GiB
 Name: alex
 ID: 5009e496-3d06-49c4-9d75-35f5b4f0cbdb
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 7
  • Comments: 24 (9 by maintainers)

Most upvoted comments

I think it’s related to: https://github.com/moby/moby/pull/49899

Looks like most of the time is spent on calculating the size of buildkit cache snapshots:

Image

Combining that with:

jun 03 10:28:30 alex dockerd[133186]: time="2025-06-03T10:28:30.168038788-03:00" level=warning msg="Not using native diff for overlay2, this may cause degraded performance for building images: kernel has CONFIG_OVERLAY_FS_REDIRECT_DIR enabled" storage-driver=overlay2

To confirm this, please disable buildkit GC in your daemon.json:

{
  ...
  "builder": {
    "gc": {
      "enabled": false
    }
}

If that helps, and you want to keep the Buildkit GC on, you can temporarily disable the redirect_dir and restart the daemon to see if it helps:

echo 0 > /sys/module/overlay/parameters/redirect_dir

and then considering making it off by default.

How big is your build cache (docker buildx du)?

I have a feeling that the CPU/memory spike is caused by the initial GC run. Before 28.2.0 the GC wasn’t enabled by default, so your build cache was piling up. Then after you upgraded to 28.2.0 the GC kicked in and started deleting the old build cache. That also explains why it eventually stopped for some people (and we mistakenly attributed that to disabling the CDI).

cc @crazy-max @tonistiigi - is this expected for the GC to cause such high CPU and memory usage?

It could be it. I had like 300GB cache but I did also a docker system prune. This could explain why I was not able to reproduce it anymore.