podman build layer finalization slows in 5.8.7 vs 5.8.4 with fuse-overlayfs in Kubernetes
Issue Description
In a Kubernetes CI executor running rootful Podman inside a container, podman build using the official quay.io/podman/stable image became about 3 times slower between Podman 5.8.4 and 5.8.7. The slowdown is concentrated in the silent period after a RUN command finishes and before the next STEP appears. The measured build does not include a registry push or CI artifact creation/upload.
We compared the same immutable application source and Dockerfile on the same Kubernetes worker, using these pinned image digests:
- 5.8.4:
quay.io/podman/stable@sha256:3c99be9108dacd2b25d2f343c91386abd14a5ceaca68aa3e8d7f6ee2ebd50a16 - 5.8.7:
quay.io/podman/stable@sha256:0da679a76d0ec35880419caeaf89b3627c3fbbc8e6cbf5456b69368b58bac628
Both images use the overlay storage driver with fuse-overlayfs 1.17, ext4 backing storage, and Native Overlay Diff: false. This may involve Buildah or containers/storage layer finalization; the timing evidence alone does not establish which component is responsible.
Steps to reproduce the issue
The generic probe below runs in two sequential Kubernetes CI pods, once per image digest above. Both pods use the same runner configuration. The 128 MB single-file layer alone finishes quickly on both versions. Adding 50,000 small files makes the difference visible.
FROM alpine:3.20
RUN dd if=/dev/zero of=/blob bs=1M count=128 && date -u '+payload_finished=%Y-%m-%dT%H:%M:%SZ'
RUN mkdir /small-files && i=0; while [ "$i" -lt 50000 ]; do printf '%08d\n' "$i" > "/small-files/file-$i"; i=$((i + 1)); done; date -u '+small_files_finished=%Y-%m-%dT%H:%M:%SZ'
RUN date -u '+next_step_started=%Y-%m-%dT%H:%M:%SZ'
Run podman build --no-cache -t localhost/podman-probe:latest . with timestamped CI logs. No registry push is involved.
Describe the results you received
| Measurement | 5.8.4 | 5.8.7 |
|---|---|---|
Full application podman build |
586 s | 1,782 s |
yarn install command itself |
151 s | 203 s |
Quiet period after yarn install until next STEP |
142 s | 764 s |
yarn build command itself |
186 s | 193 s |
Quiet period after yarn build until next STEP |
82 s | 569 s |
Generic probe: 50,000-file RUN completion to next STEP |
21 s | 36 s |
Generic probe: final COMMIT to build_finished |
14 s | 27 s |
The application image is approximately 1.69 GB. The actual application commands changed much less than the inter-step pauses. The generic probe showed the same direction but a smaller effect: total CI job time was 57 s versus 84 s. A single 128 MB file without the many-file layer took only about 12 s versus 14 s per CI job.
Describe the results you expected
Layer finalization on 5.8.7 should be comparable to 5.8.4 for the same source and storage configuration, or the difference should be explained by an intended change.
podman info output
Relevant sanitized fields from both runs:
host:
os: linux
arch: amd64
kernel: 6.8.0-1067-azure
store:
graphDriverName: overlay
graphOptions:
overlay.mount_program: /usr/bin/fuse-overlayfs
overlay.mountopt: nodev,fsync=0
graphStatus:
Backing Filesystem: extfs
Native Overlay Diff: "false"
Supports d_type: "true"
Using metacopy: "false"
backingMountFilesystem: ext4
fuse-overlayfs: "1.17"
Podman in a container
Yes, in a Kubernetes CI pod.
Privileged Or Rootless
Rootful Podman in the CI container.
Upstream Latest Release
No. The latest upstream release is 6.1.2. This report compares the supported 5.8 series supplied by the official quay.io/podman/stable image; v6.1.2 is not available as a tag on that image. We tested the latest 5.8 image available to this pipeline.
Additional environment details
Linux amd64 Kubernetes executor; the Podman container runs on a Linux worker with an ext4-backed writable container layer. The regression was observed with unchanged application build inputs and then checked with the generic Dockerfile above. The exact application repository and private CI logs are not public; sanitized timestamps and timings are included here.
There are significant pkg/archive changes to fix several archive security vulnerabilities. The amount of bump here surprises me, it may be that we are doing "to much" extra work or maybe the syscall overhead is just that much. Do you see similar numbers without fuse-overlayfs, i.e. native kernel overlay?
cc @mtrmac @giuseppe
I do not have an easy way to test it with different settings
Can you install strace and run the podman build command with strace -f -c podman build ... and then paste the syscalls counts in both cases. I wonder if we do a lot more syscalls now.
I ran the probe from the issue description under strace -f -c -S calls -o <file> podman build --no-cache ... (strace 7.2) in the same Kubernetes CI runner setup: rootful Podman, fuse-overlayfs 1.17, ext4 backing storage, kernel 6.8.0-1067-azure. The two jobs ran sequentially in one pipeline. alpine:3.20 was pulled before the traced build.
The 5.8.7 digest from the original report was a daily rebuild that Quay has since expired, so this run uses the immutable 5.8.7 image instead:
- 5.8.4:
quay.io/podman/stable@sha256:3c99be9108dacd2b25d2f343c91386abd14a5ceaca68aa3e8d7f6ee2ebd50a16 - 5.8.7:
quay.io/podman/stable@sha256:f345d8d4fddea244d3a1ced27bcec82d14cc9e32cb5ead7f5882b0baf59dc8b0(v5.8.7-immutable)
5.8.7 makes about twice as many syscalls in total: 19.8M vs 10.1M. A second 5.8.4 run in a separate pipeline was within 0.3% of the first (10.09M vs 10.12M).
| syscall | 5.8.4 calls | 5.8.7 calls | delta | ratio | 5.8.4 errors | 5.8.7 errors |
|---|---|---|---|---|---|---|
read |
1,450,981 | 2,894,647 | +1,443,666 | 1.99x | 78 | 77 |
writev |
1,094,492 | 2,537,662 | +1,443,170 | 2.32x | 0 | 0 |
splice |
1,044,756 | 2,487,927 | +1,443,171 | 2.38x | 9 | 9 |
fcntl |
458,652 | 2,283,572 | +1,824,920 | 4.98x | 0 | 0 |
close |
507,323 | 1,684,679 | +1,177,356 | 3.32x | 0 | 0 |
openat |
104,799 | 1,282,155 | +1,177,356 | 12.23x | 406 | 406 |
nanosleep |
694,140 | 1,216,205 | +522,065 | 1.75x | 13 | 10 |
futex |
669,682 | 757,930 | +88,248 | 1.13x | 54,829 | 60,354 |
statx |
694,722 | 695,612 | +890 | 1.00x | 52,953 | 52,953 |
epoll_ctl |
152,109 | 608,340 | +456,231 | 4.00x | 51,266 | 507,496 |
lgetxattr |
558,428 | 305,314 | -253,114 | 0.55x | 558,407 | 305,293 |
llistxattr |
406,224 | 203,112 | -203,112 | 0.50x | 0 | 0 |
getxattr |
0 | 253,114 | +253,114 | new | 0 | 253,114 |
listxattr |
0 | 203,112 | +203,112 | new | 0 | 0 |
| total | 10,121,588 | 19,789,291 | +9,667,703 | 1.96x | 1,450,664 | 1,911,263 |
The traced timings follow the same pattern as before (strace slows both runs):
| Phase (under strace) | 5.8.4 | 5.8.7 |
|---|---|---|
50,000-file RUN finished to next STEP |
160 s | 361 s |
Final RUN started to build finished (includes COMMIT) |
138 s | 278 s |
Whole podman build |
393 s | 738 s |
What stands out in the counts (my reading, not verified further):
openatandcloseboth grow by exactly 1,177,356. That is roughly 23 extra open/close pairs for each of the 50,000 files.read,writevandspliceeach grow by about 1.44M. With-fthese most likely come from thefuse-overlayfsrequest loop. If so, the extra opens go through the FUSE mount, which would explain why fuse-overlayfs setups are hit harder.fcntl(+1.82M) andepoll_ctl(+456k, almost all failing with errors) also grow. Theepoll_ctlfailures look like Go's poller rejecting regular-file descriptors that are now opened more often.- About half of the
lgetxattr/llistxattrcalls moved togetxattr/listxattr, with the same totals. That points to xattrs now being read through a path other than the original one, probably a/proc/self/fd/N-style path.
These are aggregated -f counts, so they don't separate Podman from fuse-overlayfs. I can rerun with per-process output if that would help.
5.8.4 full strace -f -c summary
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ------------------
1.28 9.097290 6 1450981 78 read
1.36 9.672839 8 1094492 writev
1.57 11.199983 10 1044756 9 splice
0.61 4.365677 6 694722 52953 statx
7.29 51.874643 74 694140 13 nanosleep
67.22 478.644050 714 669682 54829 futex
1.03 7.298752 13 558428 558407 lgetxattr
0.42 2.986967 5 507323 close
0.31 2.228493 4 458652 fcntl
0.69 4.879318 12 406224 llistxattr
0.33 2.350366 5 402984 402984 fgetxattr
0.53 3.789298 10 364834 12201 write
0.94 6.674099 18 355640 50474 newfstatat
0.30 2.138108 6 310187 259871 faccessat2
0.52 3.673949 12 305805 3377 openat2
0.13 0.938963 6 152109 51266 epoll_ctl
0.34 2.431571 23 104799 406 openat
0.15 1.088860 10 100029 dup2
7.10 50.577986 563 89824 68 epoll_pwait
0.09 0.608490 7 80429 utimensat
0.21 1.488119 29 50406 196 unlinkat
0.10 0.721283 14 50330 pwrite64
0.06 0.425737 8 50026 fchmodat
0.19 1.373270 27 50002 open
0.02 0.121046 14 8351 getpid
0.01 0.076479 9 8162 2366 rt_sigreturn
0.03 0.195702 24 8103 tgkill
0.03 0.182677 23 7862 sched_yield
0.00 0.026457 3 7618 rt_sigaction
0.01 0.076226 12 6026 mmap
0.03 0.208236 42 4857 getdents64
0.01 0.056636 13 4178 108 readlinkat
0.00 0.015455 5 2835 fstat
0.00 0.028669 13 2179 rt_sigprocmask
0.00 0.022711 13 1706 mprotect
0.00 0.015471 9 1602 prctl
0.00 0.013101 8 1505 pread64
0.00 0.027188 18 1485 37 madvise
0.00 0.008427 14 588 sigaltstack
0.00 0.005924 10 553 sched_getaffinity
0.00 0.005315 9 542 brk
0.00 0.002325 6 373 259 seccomp
0.00 0.008628 24 347 munmap
0.00 0.003598 11 327 set_robust_list
0.00 0.002999 9 319 160 statfs
0.00 0.004428 13 318 rseq
0.00 0.001972 6 317 302 readlink
0.00 0.001361 4 304 getuid
0.00 0.004843 16 294 gettid
0.00 0.018753 72 257 clone3
0.00 0.001833 7 250 getrandom
0.00 0.002649 11 222 prlimit64
0.00 0.000501 2 210 dup3
0.00 0.002170 10 207 pipe2
0.00 0.007417 37 198 66 mkdirat
0.00 0.006822 35 192 6 renameat
0.00 0.000997 5 190 geteuid
0.00 0.001907 12 158 lseek
0.00 0.001425 9 152 134 access
0.00 0.030305 199 152 fdatasync
0.00 0.001802 12 146 fchmod
0.00 0.002977 21 137 3 mount
0.00 0.000732 6 120 chdir
0.00 0.000624 7 83 capget
0.00 0.012851 176 73 clone
0.00 0.000339 4 71 set_tid_address
7.00 49.849579 702106 71 7 waitid
0.00 0.000364 5 69 arch_prctl
0.00 0.013181 209 63 execve
0.00 0.000434 7 61 fstatfs
0.00 0.000589 10 57 socket
0.00 0.000291 5 57 getsockname
0.00 0.000436 8 54 recvmsg
0.00 0.000387 7 51 fchown
0.00 0.000269 5 46 23 name_to_handle_at
0.00 0.000326 7 45 vmsplice
0.00 0.000369 9 37 eventfd2
0.00 0.000385 10 37 epoll_create1
0.00 0.000404 11 36 connect
0.00 0.000896 29 30 25 stat
0.00 0.000415 13 30 chroot
0.00 0.000369 15 24 setgroups
0.00 0.000025 1 24 setresuid
0.00 0.000327 13 24 setresgid
0.00 0.001159 48 24 fchownat
0.04 0.310588 14117 22 3 umount2
0.00 0.000291 13 21 sendto
0.00 0.000149 7 21 bind
0.00 0.000090 4 19 umask
0.00 0.000205 10 19 fsetxattr
0.00 0.000111 6 18 getcwd
0.00 0.000713 39 18 unlink
0.00 0.000092 5 18 getrlimit
0.00 0.000081 6 12 uname
0.00 0.000070 5 12 fchdir
0.00 0.000064 5 12 getppid
0.00 0.000134 11 12 flistxattr
0.00 0.023959 1996 12 ppoll
0.00 0.000362 30 12 renameat2
0.00 0.000050 4 12 12 copy_file_range
0.00 0.000067 7 9 poll
0.00 0.000152 16 9 recvfrom
0.00 0.000046 5 9 getgid
0.00 0.000072 8 9 getegid
0.00 0.000000 0 9 setsid
0.00 0.000047 5 9 9 mknodat
0.00 0.000563 62 9 unshare
0.00 0.000198 28 7 3 mkdir
0.00 0.000024 3 7 pidfd_send_signal
0.00 0.000021 3 7 pidfd_open
0.00 0.000882 147 6 3 pivot_root
0.00 0.000146 24 6 symlinkat
0.00 0.000079 13 6 memfd_create
0.00 0.004483 747 6 execveat
0.00 0.000012 2 5 getrusage
0.00 0.000034 8 4 4 ioctl
0.01 0.072327 18081 4 2 wait4
0.00 0.000021 7 3 dup
0.00 0.003201 1067 3 fsync
0.00 0.000000 0 3 capset
0.00 0.000137 45 3 restart_syscall
0.00 0.000194 97 2 fork
------ ----------- ----------- --------- --------- ------------------
100.00 712.027959 70 10121588 1450664 total
5.8.7 full strace -f -c summary
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ------------------
1.42 17.791135 6 2894647 77 read
1.66 20.783825 8 2537662 writev
1.96 24.556591 9 2487927 9 splice
0.95 11.944941 5 2283572 fcntl
1.01 12.619923 7 1684679 close
1.39 17.417330 13 1282155 406 openat
9.07 113.588812 93 1216205 10 nanosleep
65.28 817.496934 1078 757930 60354 futex
0.36 4.448893 6 695612 52953 statx
0.27 3.441859 5 608340 507496 epoll_ctl
0.53 6.622553 16 405644 50474 newfstatat
0.19 2.420233 6 402984 402984 fgetxattr
0.30 3.766589 10 365314 12184 write
0.17 2.104544 6 310187 259871 faccessat2
0.29 3.614646 11 305805 3377 openat2
0.26 3.261483 10 305314 305293 lgetxattr
0.36 4.495453 17 253114 253114 getxattr
0.28 3.567068 17 203112 listxattr
0.15 1.891220 9 203112 llistxattr
0.08 1.054493 10 100029 dup2
9.48 118.744366 1230 96509 133 epoll_pwait
0.05 0.611670 7 81301 utimensat
0.11 1.413513 28 50406 196 unlinkat
0.06 0.714315 14 50330 pwrite64
0.03 0.421275 8 50026 fchmodat
0.11 1.335334 26 50002 open
0.02 0.240564 13 17493 getpid
0.01 0.185353 10 17307 1088 rt_sigreturn
0.03 0.408708 23 17248 tgkill
0.01 0.184239 15 11810 sched_yield
0.00 0.024539 3 7618 rt_sigaction
0.01 0.074694 12 6018 mmap
0.02 0.217970 44 4861 getdents64
0.00 0.056959 13 4256 186 readlinkat
0.00 0.016305 5 2847 fstat
0.00 0.027684 12 2179 rt_sigprocmask
0.00 0.041821 21 1937 37 madvise
0.00 0.017353 9 1848 pread64
0.00 0.021055 12 1703 mprotect
0.00 0.013868 8 1594 prctl
0.00 0.009038 10 896 sched_getaffinity
0.00 0.009485 16 588 sigaltstack
0.00 0.005328 9 543 brk
0.00 0.003490 9 373 259 seccomp
0.00 0.007386 21 349 munmap
0.00 0.003603 11 327 set_robust_list
0.00 0.002567 8 319 160 statfs
0.00 0.004831 15 318 rseq
0.00 0.002338 7 317 302 readlink
0.00 0.001230 4 304 getuid
0.00 0.003914 13 294 gettid
0.00 0.017129 66 257 clone3
0.00 0.001701 6 251 getrandom
0.00 0.001688 7 222 prlimit64
0.00 0.000658 3 210 dup3
0.00 0.002385 11 207 pipe2
0.00 0.006831 34 198 66 mkdirat
0.00 0.006938 36 192 6 renameat
0.00 0.000897 4 190 geteuid
0.00 0.001706 10 158 lseek
0.00 0.001563 10 152 134 access
0.00 0.034136 224 152 fdatasync
0.00 0.001830 12 146 fchmod
0.00 0.002572 18 137 3 mount
0.00 0.000922 7 120 chdir
0.00 0.000237 2 83 capget
0.00 0.016406 224 73 clone
0.00 0.000325 4 71 set_tid_address
3.99 49.970907 703815 71 7 waitid
0.00 0.000321 4 69 arch_prctl
0.00 0.014271 226 63 execve
0.00 0.000379 6 61 fstatfs
0.00 0.000545 9 57 socket
0.00 0.000275 4 57 getsockname
0.00 0.000479 8 54 recvmsg
0.00 0.000363 7 51 fchown
0.00 0.000312 6 46 23 name_to_handle_at
0.00 0.000290 6 45 vmsplice
0.00 0.000266 7 37 eventfd2
0.00 0.001309 35 37 epoll_create1
0.00 0.000398 11 36 connect
0.00 0.000696 23 30 25 stat
0.00 0.000193 6 30 chroot
0.00 0.000764 31 24 fchownat
0.00 0.000536 23 23 setgroups
0.00 0.000320 13 23 setresuid
0.00 0.000396 17 23 setresgid
0.02 0.304100 13822 22 3 umount2
0.00 0.000263 12 21 sendto
0.00 0.000121 5 21 bind
0.00 0.000100 5 19 umask
0.00 0.000212 11 19 fsetxattr
0.00 0.000098 5 18 getcwd
0.00 0.000657 36 18 unlink
0.00 0.000136 7 18 getrlimit
0.00 0.000123 10 12 uname
0.00 0.000033 2 12 fchdir
0.00 0.000043 3 12 getppid
0.00 0.000186 15 12 flistxattr
0.00 0.000333 27 12 renameat2
0.00 0.000084 7 12 12 copy_file_range
0.00 0.025340 2534 10 ppoll
0.00 0.000065 7 9 poll
0.00 0.000036 4 9 recvfrom
0.00 0.000055 6 9 getgid
0.00 0.000044 4 9 getegid
0.00 0.000073 8 9 setsid
0.00 0.000060 6 9 9 mknodat
0.00 0.000518 57 9 unshare
0.00 0.000189 27 7 3 mkdir
0.00 0.000058 8 7 pidfd_send_signal
0.00 0.000089 12 7 pidfd_open
0.00 0.000230 38 6 3 pivot_root
0.00 0.000172 28 6 symlinkat
0.00 0.000076 12 6 memfd_create
0.00 0.004054 675 6 execveat
0.00 0.000026 5 5 getrusage
0.00 0.000032 8 4 4 ioctl
0.01 0.072476 18119 4 2 wait4
0.00 0.000019 6 3 dup
0.00 0.000767 255 3 fsync
0.00 0.000000 0 3 capset
0.00 0.000259 129 2 fork
------ ----------- ----------- --------- --------- ------------------
100.00 1252.215391 63 19789291 1911263 total
I could reproduce this locally outside Kubernetes. I ran the two quay.io/podman/stable images as privileged Docker Desktop containers (WSL2 kernel 6.18) with /var/lib/containers on an ext4 volume. The smallest case that shows the slowdown needs no build at all: podman commit of a container that created many small files.
# inside a privileged quay.io/podman/stable container (default storage.conf: fuse-overlayfs)
podman run --name filler docker.io/library/alpine:3.20 sh -c \
'mkdir /small-files && i=0; while [ $i -lt 50000 ]; do echo $i > /small-files/file-$i; i=$((i+1)); done'
time podman commit -q filler localhost/committed:latest
For native overlay I commented out mount_program and set mountopt = "nodev", because the kernel overlay rejects fsync=0. That gives Native Overlay Diff: true.
Timings with 50,000 files, one run each, no strace:
| 5.8.4 | 5.8.7 | ratio | |
|---|---|---|---|
fuse-overlayfs: podman commit |
60.6 s | 96.4 s | 1.59x |
fuse-overlayfs: podman build (probe without the 128 MB step) |
96.5 s | 161.1 s | 1.67x |
native overlay: podman commit |
6.8 s | 9.1 s | 1.34x |
native overlay: podman build |
11.9 s | 13.7 s | 1.15x |
Images: 5.8.4 sha256:3c99be9108dacd2b25d2f343c91386abd14a5ceaca68aa3e8d7f6ee2ebd50a16, 5.8.7 sha256:f345d8d4fddea244d3a1ced27bcec82d14cc9e32cb5ead7f5882b0baf59dc8b0 (v5.8.7-immutable).
To see which process makes the extra calls, I traced only the podman commit, with 10,000 files, using strace -f -Y (the -Y flag labels each call with the process name):
| process | fuse 5.8.4 | fuse 5.8.7 | native 5.8.4 | native 5.8.7 |
|---|---|---|---|---|
podman |
166,824 | 705,617 | 142,256 | 462,470 |
fuse-overlayfs |
482,698 | 1,005,070 | – | – |
exe (storage chroot) |
120,455 | 130,465 | 120,459 | 130,460 |
Only a subset of syscalls was traced: open/close, fcntl, epoll_ctl, xattr, stat, and read/writev/splice.
The extra calls come from the podman process while it generates the layer diff. fuse-overlayfs then has to serve each of them. For each file, 5.8.4 makes a few calls on the full absolute path: newfstatat, lgetxattr, llistxattr and a single openat. With fuse-overlayfs that path is under merged/; with native overlay it is under diff/. 5.8.7 resolves paths relative to directory file descriptors instead:
openat(9, "file-1234", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 10 # x3, one per xattr call
openat(9, "file-1234", O_RDONLY|O_NOFOLLOW|O_CLOEXEC) = 10
The parent directory is also reopened for almost every file. With 10,000 files in /small-files, 5.8.7 opens small-files 80,007 times with fuse-overlayfs and 50,006 times with native overlay. file-N is opened 60,000 and 40,000 times. The xattr reads moved from lgetxattr/llistxattr to getxattr/listxattr, which suggests they now go through a /proc/self/fd/N path.
My guess, not verified in the code: if every xattr or stat call on an entry re-walks the path from the root one component at a time, the cost grows with path depth as well as file count. That would explain why our real build is hit much harder than this flat probe. Its slow steps are yarn install and yarn build, which write deep node_modules trees; the pause after yarn install went from 142 s to 764 s.
I bisected this to podman-container-tools/container-libs@5f654a0359db4052c925139ad8628ff85aef5dea, "Make creating tars, Changes etc. safe against concurrent modification". It shipped in go.podman.io/storage v1.62.1, which Podman 5.8.7 vendors; 5.8.4 has v1.62.0. The same change is d5a0c9d42 on main.
Between the two storage releases, only the archive.TarWithOptions path changed noticeably. I checked that with a small Go program built against four storage source trees. It tars 50,000 five-byte files and discards the output. The files sit either directly under the root (depth 1) or eight directories deep (depth 8). Data was on ext4, run in golang:1.25, and each number is the best of 3 runs. No FUSE is involved:
| storage source | depth 1 | depth 8 | syscalls (depth 1, strace -f -c) |
|---|---|---|---|
storage/v1.62.0 |
1.15 s | 1.27 s | 876,381 |
2fc1207df (parent of the commit) |
1.14 s | 1.29 s | 874,620 |
5f654a035 |
3.50 s | 9.10 s | 2,998,262 |
storage/v1.62.1 |
3.33 s | 8.85 s | 3,009,546 |
The per-file syscall counts at depth 1, before → after the commit: openat 1 → 9, close 1 → 9, fcntl 4 → 16, epoll_ctl 1 → 4 (all failing), and newfstatat 1 → 2. The lgetxattr/llistxattr calls become getxattr/listxattr on /proc/self/fd/N.
The cause seems to be that RootLgetxattr and RootLlistxattr each call root.Open(path.Dir(fsPath)). That walks the parent directory again from the root and wraps it in an *os.File (hence the fcntl and epoll_ctl calls). They then open the entry O_PATH for a single xattr call. addTarFile calls these per xattr and also does root.Lstat and root.Open, so every file entry resolves its parent path several times. The cost grows with depth: 50,000 files at depth 8 take 7x longer, versus 3x at depth 1.
With fuse-overlayfs and Native Overlay Diff: false, the diff is generated by walking merged/. Every one of those extra lookups becomes a FUSE request, which is why our CI builds, with deep node_modules trees, slowed so much more (the pause after yarn install went from 142 s to 764 s).
A possible fix, which I haven't tried: open the parent directory once per directory during the walk and reuse that fd for the stat, xattr and open calls on every entry in it, or at least once per entry. That would keep the concurrent-modification safety without re-walking the path for each call.
cc @mtrmac
thanks for the numbers, if confirmed this looks like a serious regression. The effect is more visible with fuse-overlayfs because for IO syscall done by Podman will also cause more work for fuse-overlayfs
Some of the overhead is ~unavoidable to get the extra security but I didn’t anticipate that high a cost.
Ultimately the cause is that every single operation on an os.Root walks the entire path, in userspace. That should get better via https://github.com/golang/go/issues/73077 (with a pending PR), but probably only in a future Go version. Still, that sort of limits how much effort it is worthwhile to spend on a temporary alternative.
A possible fix, which I haven't tried: open the parent directory once per directory during the walk and reuse that fd for the stat, xattr and open calls on every entry in it
I agree that would be conceptually ideal; it’s not trivially possible given the io/fs.WalkDir implementation (and we can’t keep a handle for every parent directory open because that can run into handle limits with deeply nested structures).
or at least once per entry.
Yes, that should be easier to handle, although still not costless (when getting a file descriptor out of os.Root requires an extra open() syscall). And for the best possible performance we’d need to have a special Linux code path, ugh.
https://github.com/podman-container-tools/container-libs/pull/1216 is what we can easily do; more could be done, with more intrusive changes.
If you happened to already have a benchmarking set up / scripted, I’d appreciate running that against this version, to possibly reveal unanticipated surprises — full disclosure, I didn’t do any measurements myself yet.
Thanks! I ran podman-container-tools/container-libs#1216 (head 9d6041549) against its merge base on main (cbc3ed865) and both 1.62 releases. PR #1216 helps a lot for deep trees and does nothing for flat ones. ChangesDirs is untouched, and on fuse-overlayfs it is now the biggest remaining cost of the naive diff.
Setup. I built a static Go program once per storage source tree. It times TarWithOptions, ChangesDirs(tree, empty) and ExportChanges(tree, changes), draining the tar streams to io.Discard. Each tree holds small files in a single directory, either one level deep (level0/file-N) or eight levels deep (level0/.../level7/file-N). It ran under Docker Desktop (WSL2 kernel 6.18.40):
- ext4: files on an ext4 volume.
- fuse-overlayfs 1.17: files in an overlay upper directory with an empty lower directory, read through the
mergedmount. That is the same pathNaiveDiffDriverwalks whenNative Overlay Diff: false.
Every number is the best of 4 runs (2 interleaved rounds × 2 runs).
| filesystem | tree | operation | v1.62.0 | v1.62.1 | main base | PR #1216 | PR vs main |
|---|---|---|---|---|---|---|---|
| ext4, 50,000 files | 1 level | tar | 1.17 s | 3.29 s | 3.23 s | 3.11 s | -4% |
| ext4, 50,000 files | 1 level | changes | 0.48 s | 1.72 s | 1.68 s | 1.76 s | +5% |
| ext4, 50,000 files | 1 level | export | 3.33 s | 6.06 s | 6.02 s | 5.96 s | -1% |
| ext4, 50,000 files | 8 levels | tar | 1.26 s | 8.81 s | 8.84 s | 4.19 s | -53% |
| ext4, 50,000 files | 8 levels | changes | 0.59 s | 5.21 s | 5.09 s | 5.00 s | -2% |
| ext4, 50,000 files | 8 levels | export | 3.55 s | 11.75 s | 11.59 s | 7.03 s | -39% |
| fuse-overlayfs, 20,000 files | 1 level | tar | 8.40 s | 16.34 s | 16.04 s | 15.70 s | -2% |
| fuse-overlayfs, 20,000 files | 1 level | changes | 3.30 s | 8.22 s | 7.99 s | 8.71 s | +9% |
| fuse-overlayfs, 20,000 files | 1 level | export | 8.05 s | 16.22 s | 16.09 s | 15.47 s | -4% |
| fuse-overlayfs, 20,000 files | 8 levels | tar | 8.31 s | 64.89 s | 67.63 s | 25.82 s | -62% |
| fuse-overlayfs, 20,000 files | 8 levels | changes | 3.30 s | 37.37 s | 41.11 s | 39.45 s | -4% |
| fuse-overlayfs, 20,000 files | 8 levels | export | 8.26 s | 65.15 s | 69.23 s | 25.44 s | -63% |
What I see:
- Deep trees:
tarandexportdrop by 39–63%. The PR stops re-resolving the parent path for every operation on an entry. The remaining gap to v1.62.0 is still 2–3.3x (ext4 tar 4.19 s vs 1.26 s; fuse-overlayfs export 25.4 s vs 8.3 s). - Flat directories: no measurable change. With one level, every entry still pays for
root.OpenRoot(parent)plus the per-entry calls, and that costs about the same as before. ChangesDirs: unchanged by the PR and still 2.6–12x slower than v1.62.0. On fuse-overlayfs with 8 levels it takes 39 s versus 3.3 s.NaiveDiffDriver.DiffrunsChangesDirsand thenExportChanges, so a fuse-overlayfs commit of that tree costs about 11.6 s on v1.62.0, 110 s on the main base and 65 s with the PR. Once the PR is in,ChangesDirsaccounts for about 60% of what remains.
Every run finished without errors (the harness aborts on any error), but I only measured timing, not output. I haven't benchmarked a Podman build with the PR vendored. I can do that if a test binary or image is available.
OK, another version of https://github.com/podman-container-tools/container-libs/pull/1216 .
- Caches open directory handles much more
- Reimplements
ChangesDirsto also keep individual-directory handles - The xattr changes now cache the directory handle, as well as the individual handle.
Microbenchmarks in a non-representative environment suggest that this should be broadly comparable to the previous code. To do more, we would have to reimplement fs.WalkDir (and that might result in a small speedup), and I’d really prefer to avoid that complexity.
Thanks, this version fixes it in my benchmark. On fuse-overlayfs it is within 7% of v1.62.0, and on ext4 it is close (details below).
The harness is the same as last time: one static Go program per storage source tree, timing TarWithOptions, ChangesDirs(tree, empty) and ExportChanges(tree, changes) under Docker Desktop (WSL2 kernel 6.18.40). Trees hold small files either one level deep or eight levels deep. The fuse-overlayfs 1.17 runs read through a merged mount whose upper directory holds the tree. Every number is the best of 4 runs (2 interleaved rounds × 2 runs). I compared:
v1.62.0- the current merge base on
main(30367a80b) - the previous version of the PR (
9d6041549) - this version (
135510e80)
| filesystem | tree | operation | v1.62.0 | main base | PR, previous | PR, this version | this version vs main |
|---|---|---|---|---|---|---|---|
| ext4, 50,000 files | 1 level | tar | 1.07 s | 3.14 s | 2.97 s | 1.52 s | -52% |
| ext4, 50,000 files | 1 level | changes | 0.43 s | 1.67 s | 1.65 s | 0.75 s | -55% |
| ext4, 50,000 files | 1 level | export | 3.29 s | 5.90 s | 5.74 s | 4.14 s | -30% |
| ext4, 50,000 files | 8 levels | tar | 1.20 s | 8.53 s | 4.10 s | 1.51 s | -82% |
| ext4, 50,000 files | 8 levels | changes | 0.56 s | 4.94 s | 5.01 s | 0.77 s | -84% |
| ext4, 50,000 files | 8 levels | export | 3.46 s | 11.27 s | 6.93 s | 4.10 s | -64% |
| fuse-overlayfs, 20,000 files | 1 level | tar | 7.71 s | 15.25 s | 14.02 s | 7.89 s | -48% |
| fuse-overlayfs, 20,000 files | 1 level | changes | 3.09 s | 7.74 s | 7.76 s | 3.32 s | -57% |
| fuse-overlayfs, 20,000 files | 1 level | export | 7.54 s | 15.46 s | 13.96 s | 7.79 s | -50% |
| fuse-overlayfs, 20,000 files | 8 levels | tar | 7.93 s | 62.88 s | 23.51 s | 7.97 s | -87% |
| fuse-overlayfs, 20,000 files | 8 levels | changes | 3.24 s | 36.48 s | 36.30 s | 3.38 s | -91% |
| fuse-overlayfs, 20,000 files | 8 levels | export | 7.66 s | 63.16 s | 23.47 s | 7.92 s | -87% |
- fuse-overlayfs: this version is within 7% of v1.62.0 for every operation and depth. The naive-diff commit of the 8-level tree (
ChangesDirs+ExportChanges) takes 11.3 s, versus 10.9 s on v1.62.0 and 99.6 s on the main base. - ext4: some overhead remains. Compared with v1.62.0, tar is 26–42% slower, changes 37–74% and export 18–26%, but all far below the main base.
- Correctness: besides timing, each version ran once untimed, hashing the sorted tar headers (name, type, mode, size, uid/gid, link name, PAX records) of both the
TarWithOptionsand theExportChangesoutput. It also counted the changes fromChangesDirs. Each tree contains a symlink, a hard link, an executable, a 0750 directory and a file with auser.*xattr in addition to the plain files. All four versions produced identical digests and change counts on both filesystems at both depths.
I haven't run a full Podman build with this vendored; the numbers above are library-level only.
For the record, the fix is
- https://github.com/podman-container-tools/container-libs/pull/1216 on
main - https://github.com/podman-container-tools/container-libs/pull/1228 on
podman-6.1 - https://github.com/podman-container-tools/container-libs/pull/1229 on
podman-5.8
I ran end-to-end podman build benchmarks with the released fixes (v5.8.9 and v6.1.4). Both fix the regression for us; a small residual cost per layer commit remains.
Setup. Docker Desktop on WSL2 (kernel 6.18.40). Every run used the same Fedora 44 base image (quay.io/podman/stable v5.8.7-immutable), with only /usr/bin/podman replaced by a binary built from the upstream tag (go1.26.9, default Makefile tags):
- v5.8.4 vendors storage v1.62.0
- v5.8.7 vendors storage v1.62.1
- v5.8.9 vendors storage v1.62.2
- v6.1.4 vendors storage v1.64.2
Each run got fresh ext4 volumes for /var/lib/containers and /var/tmp. I tested both the image's default fuse-overlayfs 1.17 setup (Native Overlay Diff: false) and native kernel overlay. Builds used podman build --no-cache --pull=never in 2 interleaved rounds, and all 48 builds succeeded. "Commit pause" is the time from a step's last output line to its --> <id> line.
The workloads were:
- the probe from this issue;
- a synthetic node_modules-like tree with about 48,500 small files, 8 levels deep;
- our real application build:
node:14-alpine,COPY,yarn install,yarn build.
fuse-overlayfs, seconds (round 1 / round 2):
| v5.8.4 | v5.8.7 | v5.8.9 | v6.1.4 | |
|---|---|---|---|---|
| real app, whole build | 869 / 777 | 4,147* / 3,558 | 923 / 911 | 908 / 918 |
real app, pause after yarn install |
286 / 248 | 2,194* / 1,743 | 318 / 313 | 313 / 315 |
real app, pause after yarn build |
192 / 170 | 1,495* / 1,410 | 234 / 233 | 230 / 231 |
| deep tree, whole build | 106 / 100 | 557 / 502 | 130 / 130 | 127 / 127 |
| issue probe, whole build | 98 / 89 | 171 / 154 | 101* / 96 | 95 / 93 |
native overlay, seconds (round 1 / round 2):
| v5.8.4 | v5.8.7 | v5.8.9 | v6.1.4 | |
|---|---|---|---|---|
| real app, whole build | 330 / 337 | 386 / 392 | 337 / 344 | 338 / 346 |
real app, pause after yarn install |
50 / 50 | 106 / 107 | 59 / 61 | 59 / 60 |
| deep tree, whole build | 18 / 19 | 27 / 27 | 20 / 20 | 20 / 20 |
| issue probe, whole build | 12 / 12 | 14 / 14 | 12 / 12 | 12 / 13 |
* overlapped with unrelated load on the host; round 2 was clean.
- On fuse-overlayfs, v5.8.7 makes our real build 4.6x slower than v5.8.4. v5.8.9 and v6.1.4 bring it back to within about 5–17% of v5.8.4; run-to-run noise on v5.8.4 itself was about 10%.
- A residual cost remains in the commit pauses: about 10–35% longer than v5.8.4 on fuse-overlayfs, and about 20% longer after
yarn installon native overlay. For us that's roughly a minute per build, which is fine. - v5.8.9 and v6.1.4 perform the same.
Thanks for the quick fix. Once quay.io/podman/stable publishes a 5.8.9 image, we'll confirm it on our CI runner and drop our 5.8.4 pin.