[Rpm-maint] [PATCH] Read uncompressed patches from stdin

Jean Delvare jdelvare at suse.de
Sun Jan 25 12:28:35 UTC 2015


Hi all,

On Mon, 19 Jan 2015 17:21:26 +0100, Jean Delvare wrote:
> (...)
> For these reasons I would like to ask that commit
> 15e9e1ff64aaf986ab0dd97b9b12c3d4fb22a484 is partly reverted. In my
> experience, uncompressed patches account for 99% of patches in rpm
> packages so I believe it makes sense to optimize for this case.
> 
> Signed-off-by: Jean Delvare <jdelvare at suse.de>
> ---
>  build/parsePrep.c |   10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> --- rpm.orig/build/parsePrep.c	2015-01-19 08:14:53.673496847 +0100
> +++ rpm/build/parsePrep.c	2015-01-19 08:51:45.197107629 +0100
> @@ -62,6 +62,7 @@ static char *doPatch(rpmSpec spec, uint3
>      char *arg_patch_flags = rpmExpand("%{?_default_patch_flags}", NULL);
>      struct Source *sp;
>      char *patchcmd;
> +    rpmCompressedMagic compressed = COMPRESSED_NOT;
>  
>      for (sp = spec->sources; sp != NULL; sp = sp->next) {
>  	if ((sp->flags & RPMBUILD_ISPATCH) && (sp->num == c)) {
> @@ -80,7 +81,7 @@ static char *doPatch(rpmSpec spec, uint3
>      fn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
>  
>      /* On non-build parse's, file cannot be stat'd or read. */
> -    if ((spec->flags & RPMSPEC_FORCE) || checkOwners(fn)) goto exit;
> +    if ((spec->flags & RPMSPEC_FORCE) || rpmFileIsCompressed(fn, &compressed) || checkOwners(fn)) goto exit;
>  
>      if (db) {
>  	rasprintf(&arg_backup,
> @@ -102,7 +103,12 @@ static char *doPatch(rpmSpec spec, uint3
>  		reverse ? " -R" : "", 
>  		removeEmpties ? " -E" : "");
>  
> -    patchcmd = rpmExpand("%{uncompress: ", fn, "} | %{__patch} ", args, NULL);
> +    /* Avoid the extra cost of fork and pipe for uncompressed patches */
> +    if (compressed != COMPRESSED_NOT) {
> +	patchcmd = rpmExpand("%{uncompress: ", fn, "} | %{__patch} ", args, NULL);
> +    } else {
> +	patchcmd = rpmExpand("%{__patch} ", args, " < ", fn, NULL);
> +    }
>  
>      free(arg_fuzz);
>      free(arg_dir);

Meanwhile I have benchmarked this proposed change, and I can now tell
that the performance improvement is significant. I tested
"rpmbuild -bp" on a small package with 33 patches [1], and measured the
completion time with the "time" command. I did that multiple times with
and without the patch above applied, then averaged and compared the
results:

average real:  -7%
average user:  -8%
average sys:  -35%

In particular the savings on kernel CPU time are great, methinks. So
please consider applying this patch.

[1] Although a bit extreme, this is a real-world case:
https://build.opensuse.org/package/show/home:jdelvare:branches:devel:tools:scm/quilt
Other packages would see smaller benefits, but benefits still.

Thanks,
-- 
Jean Delvare
SUSE L3 Support


More information about the Rpm-maint mailing list