When upgrading my (C++) project to gRPC 1.39.0 (the latest), I discovered that Fedora's pkgconf seems to be slow when .pc files have many Requires: clauses. The issue from my project is googleapis/google-cloud-cpp#7052 and it has some additional context. We worked around this problem by installing and using https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz instead.
It is possible that we're doing something wrong, in which case I'd be happy to learn what it is so we can fix it. Otherwise, I'm reporting this issue in case it can be fixed in a future version of pkgconf/fedora.
Steps to reproduce
- Download the pkgconfig-files.tar.gz tarball, which contains all the
*.pc files from a fully installed copy of google-cloud-cpp, protobuf, grpc, abseil, openssl, etc. This tarball does NOT contain the compiled artifacts -- only the .pc files. This is just so that we can use pkg-config in a docker container to reproduce the problem.
- Start a new docker container w/ the above tarball mounted so that the files can be extracted into
/tmp in the image.
$ docker run --rm -it --volume=$PWD/pkgconfig-files.tar.gz:/tarball fedora:34 bash
- Within the running container, extract the tarball into
/tmp, which will put all the .pc files in a single directory
[root@b1cac6cb716c /]# tar -C /tmp -zxvf /tarball
...
[root@b1cac6cb716c /]# export PKG_CONFIG_PATH=/tmp/pkgconfig-files
- Install
pkg-config
[root@b1cac6cb716c /]# dnf install -y pkgconfig
- See how slow
pkg-config is for certain packages that contain a lot of Requires: statements.
[root@b1cac6cb716c /]# time pkg-config google_cloud_cpp_grpc_utils --libs-only-l --static
...
real 0m3.184s
user 0m3.155s
sys 0m0.028s
The above is over 3 seconds. Invoked repeatedly in our actual CI builds this adds up to over an hour of time spent in pkg-config. When we switched our builds to https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz (googleapis/google-cloud-cpp#7061), each invocation completes in a small fraction of a second.
Additional info
I don't know about the internals of pkg-config, so I don't really know what it's doing or supposed to do, but I'll say that the --debug flag produces some interesting output.
[root@b1cac6cb716c /]# pkg-config google_cloud_cpp_grpc_utils --debug 2>&1 | grep -Po '\[pkgconf.+\]' | sort | uniq -c | sort -n
...
69 [pkgconf_fragment_parse]: post-subst: [-I${includedir} -DNOMINMAX] -> [-I/usr/local/include -DNOMINMAX]
90 [pkgconf_cache_add]
90 [pkgconf_cache_remove]
180 [pkgconf_pkg_try_specific_path]
309 [pkgconf_fragment_add]
393 [pkgconf_cache_lookup]
452 [pkgconf_tuple_add]
696 [pkgconf_pkg_find]
458241 [pkgconf_pkg_ref]
458241 [pkgconf_pkg_unref]
915123 [pkgconf_pkg_verify_dependency]
915518 [pkgconf_pkg_traverse]
When upgrading my (C++) project to gRPC 1.39.0 (the latest), I discovered that Fedora's
pkgconfseems to be slow when.pcfiles have manyRequires:clauses. The issue from my project is googleapis/google-cloud-cpp#7052 and it has some additional context. We worked around this problem by installing and using https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz instead.It is possible that we're doing something wrong, in which case I'd be happy to learn what it is so we can fix it. Otherwise, I'm reporting this issue in case it can be fixed in a future version of pkgconf/fedora.
Steps to reproduce
*.pcfiles from a fully installed copy ofgoogle-cloud-cpp,protobuf,grpc,abseil,openssl, etc. This tarball does NOT contain the compiled artifacts -- only the .pc files. This is just so that we can usepkg-configin a docker container to reproduce the problem./tmpin the image.$ docker run --rm -it --volume=$PWD/pkgconfig-files.tar.gz:/tarball fedora:34 bash/tmp, which will put all the.pcfiles in a single directorypkg-configpkg-configis for certain packages that contain a lot ofRequires:statements.The above is over 3 seconds. Invoked repeatedly in our actual CI builds this adds up to over an hour of time spent in
pkg-config. When we switched our builds to https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz (googleapis/google-cloud-cpp#7061), each invocation completes in a small fraction of a second.Additional info
I don't know about the internals of pkg-config, so I don't really know what it's doing or supposed to do, but I'll say that the
--debugflag produces some interesting output.