Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 83379 - emerge unmerge is very slow
Summary: emerge unmerge is very slow
Status: RESOLVED DUPLICATE of bug 23851
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-26 07:56 UTC by Vadim
Modified: 2005-09-03 00:39 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
optimization for in place checksum of files rejected by prelink (copy-optimization.patch,1.43 KB, patch)
2005-08-09 00:26 UTC, Zac Medico
Details | Diff
checksum benchmark utility (checksum.py,818 bytes, text/plain)
2005-08-09 19:19 UTC, Zac Medico
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vadim 2005-02-26 07:56:39 UTC
Once in a while I find that I have several GB of kernel source, and decide to clean up a bit. The problem is that unmerging packages with lots of files is horribly slow. 

Manually deleting a kernel tree is several times faster than unmerging it. A strace of emerge shows things that I don't fully understand. During unmerging it appears that files are copied to files named like /var/lib/portage/prelink-checksum.tmp.25978, where the content of the files being deleted is copied. Lock files are created, and I don't really understand what prelink has to do with all this either.




Reproducible: Always
Steps to Reproduce:
1. emerge -u world
2. emerge -P kernel-dev-source



Expected Results:  
Finish in a reasonable amount of time
Comment 1 Andrew Gaffney (RETIRED) gentoo-dev 2005-02-26 11:40:53 UTC
When portage unmerges a package, it does a few checks (such as mtime and md5) on each file to make sure it is the same file that was installed. As for prelink, many people use it to speed up the execution of their binaries. This process changes the files' MD5 (and possibly the mtime). On unmerge, portage runs prelink with a certain parameter to get the MD5 of the file *before* it was prelinked, which would match up with what portage recorded if the file hasn't been modified beyond prelinking.

So, yes, portage can be painfully slow unmerging packages with lots of files, but it is necessary to ensure that files aren't deleted that shouldn't be.
Comment 2 Vadim 2005-02-26 14:07:49 UTC
Aha, that makes more sense now.

But why does it check every file? Surely this can be optimized a bit. Like running it only on libraries, for instance.

I suppose one problem is that portage doesn't seem to distinguish different kinds of files.
Comment 3 Brian Harring (RETIRED) gentoo-dev 2005-02-27 19:31:42 UTC
How to identify *cleanly* what needs to be checked?  Mass file calls? nasty, fork/exec.  Some integration of libmagic?
Etc.
Comment 4 Brian Harring (RETIRED) gentoo-dev 2005-02-27 20:46:44 UTC
Possibility of prelink --undo piped to the md5 code by chance?  Would avoid the intermediate file at least (potentially speeding it up).
Comment 5 Vadim 2005-03-07 16:20:43 UTC
Couldn't it check only/exclude certain paths?

After all, libraries are supposed to be in specific places. If one somehow ends up in /usr/src that should be treated as a bug anyway.
Comment 6 Zac Medico gentoo-dev 2005-08-08 02:32:05 UTC
(In reply to comment #4)
> Possibility of prelink --undo piped to the md5 code by chance?  Would avoid
the intermediate file at least (potentially speeding it up).

There is a prelink -o --undo-output=FILE option that could be used to direct the
output to /dev/stdout.  For non-elf files, prelink --undo returns exit status 1.

(In reply to comment #5)
> Couldn't it check only/exclude certain paths?

Maybe it could use /etc/prelink.conf.
Comment 7 Zac Medico gentoo-dev 2005-08-09 00:26:33 UTC
Created attachment 65504 [details, diff]
optimization for in place checksum of files rejected by prelink

This patch uses prelink --undo-output=prelink_tmpfile in order to avoid extra
copying.  Files rejected by prelink are checksummed in place.
Comment 8 Brian Harring (RETIRED) gentoo-dev 2005-08-09 01:49:27 UTC
Zac, speed improvement via the patch?
Offhand, don't see any issues with it (haven't done anything but read it over
though).
Aside from that, nice usage of spawn (broken up args rather then forcing bash to
do it).
Comment 9 Zac Medico gentoo-dev 2005-08-09 19:19:16 UTC
Created attachment 65568 [details]
checksum benchmark utility

Example usage: find /usr/src/linux -type f | time ./checksum.py -p

(In reply to comment #8)
> Zac, speed improvement via the patch?

I have measured a 7.75% decrease in time when this benchmark was performed on
the 2.6.12 kernel sources (no elf binaries so prelink --undo rejects every
file).	Not much difference, but measurable.
Comment 10 Zac Medico gentoo-dev 2005-09-03 00:39:04 UTC

*** This bug has been marked as a duplicate of 23851 ***