| Summary: | pseudo 1.8.1: potential performance regression | ||
|---|---|---|---|
| Product: | [Yocto Project Subprojects] Pseudo | Reporter: | Patrick Ohly <patrick.ohly> |
| Component: | pseudo | Assignee: | Joshua Lock <joshuagloe> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | High | CC: | jose.perez.carranza, mark.hatle, randy.macleod, seebs, sgw, yp.pseudo.watcher, yp.watcher |
| Version: | unspecified | ||
| Target Milestone: | 2.2 M3 | ||
| Hardware: | x86 | ||
| OS: | Multiple | ||
| Whiteboard: | |||
| OS type for building Yocto: | --- | Type of Regression: | --- |
| Verified: | Documentation change: | No (bug/feature does not impact docs) | |
| Bug Depends on: | |||
| Bug Blocks: | 9858, 9857 | ||
|
Description
Patrick Ohly
2016-07-13 18:43:34 UTC
If someone wants to reproduce: - git clone git@github.com:pohly/ostro-os.git - git checkout pseudo-performance - . oe-init-build-env - bitbake ostro-image-swupd Update: build is still running, still busy copying files, with pseudo as the bottleneck. 0: ostro-image-swupd-1.0-r0 do_rootfs (pid 27298) 81% |###################################################################### | ETA: 0:23:51 1: bundle-ostro-image-swupd-qa-bundle-a-1.0-r0 do_copy_bundle_contents (pid 27299) 2: bundle-ostro-image-swupd-qa-bundle-b-1.0-r0 do_copy_bundle_contents (pid 27300) 3: bundle-ostro-image-swupd-world-dev-1.0-r0 do_copy_bundle_contents (pid 28530) 21109 pts/1 Ss 0:01 \_ -bash 508 pts/1 S+ 0:18 | \_ python3 /data2/yocto/ostro-os/bitbake/bin/bitbake ostro-image-swupd 517 pts/1 Sl+ 1:58 | \_ python3 /data2/yocto/ostro-os/bitbake/bin/bitbake ostro-image-swupd 669 pts/1 S+ 0:09 | \_ python3 /data2/yocto/ostro-os/bitbake/bin/bitbake-worker decafbad 739 pts/1 S+ 0:00 | \_ /data2/yocto/build/ostro/intel-corei7-64/tmp-glibc/sysroots/x86_64-linux/usr/bin/pseudo bitbake-worker decafbadbee 740 pts/1 S+ 0:10 | \_ python3 /data2/yocto/ostro-os/bitbake/bin/bitbake-worker decafbadbeef 27298 ? Ss 0:01 | \_ python3 /data2/yocto/ostro-os/bitbake/bin/bitbake-worker decafbadbeef 29579 ? S 0:23 | | \_ /data2/yocto/build/ostro/intel-corei7-64/tmp-glibc/sysroots/x86_64-linux/usr/bin/opkg --volatile-cache 27299 ? Ss 0:02 | \_ python3 /data2/yocto/ostro-os/bitbake/bin/bitbake-worker decafbadbeef 27672 ? S 0:00 | | \_ /bin/sh -c tar --xattrs --xattrs-include='*' -cf - -C /data2/yocto/build/ostro/intel-corei7-64/tmp-gli 27673 ? S 0:11 | | \_ tar --xattrs --xattrs-include=* -cf - -C /data2/yocto/build/ostro/intel-corei7-64/tmp-glibc/work/i 27674 ? S 0:19 | | \_ tar -p --xattrs --xattrs-include=* -xf - -C /data2/yocto/build/ostro/intel-corei7-64/tmp-glibc/dep 27300 ? Ss 0:02 | \_ python3 /data2/yocto/ostro-os/bitbake/bin/bitbake-worker decafbadbeef 27681 ? S 0:00 | | \_ /bin/sh -c tar --xattrs --xattrs-include='*' -cf - -C /data2/yocto/build/ostro/intel-corei7-64/tmp-gli 27682 ? S 0:09 | | \_ tar --xattrs --xattrs-include=* -cf - -C /data2/yocto/build/ostro/intel-corei7-64/tmp-glibc/work/i 27683 ? S 0:18 | | \_ tar -p --xattrs --xattrs-include=* -xf - -C /data2/yocto/build/ostro/intel-corei7-64/tmp-glibc/dep 28530 ? Ss 0:02 | \_ python3 /data2/yocto/ostro-os/bitbake/bin/bitbake-worker decafbadbeef 29116 ? S 0:00 | \_ /bin/sh -c tar --xattrs --xattrs-include='*' -cf - -C /data2/yocto/build/ostro/intel-corei7-64/tmp-gli 29117 ? S 0:10 | \_ tar --xattrs --xattrs-include=* -cf - -C /data2/yocto/build/ostro/intel-corei7-64/tmp-glibc/work/i 29118 ? S 0:17 | \_ tar -p --xattrs --xattrs-include=* -xf - -C /data2/yocto/build/ostro/intel-corei7-64/tmp-glibc/dep 7329 pts/4 Ss+ 0:00 \_ -bash 32666 ? Ss 0:00 \_ /usr/lib/ssh/sftp-server 3564 ? Rs 220:59 /data2/yocto/build/ostro/intel-corei7-64/tmp-glibc/sysroots/x86_64-linux/usr/bin/pseudo -d Thanks for the in-depth analysis Patrick! It's worth explicitly stating, for anyone reading along, that Ostro OS makes heavy use of extended attributes (for SMACK and IMA) and that it's pseudo_db calls related to xattr handling which are most implicated in the traces. The meta-swupd tar usage is a tar-pipe to copy files preserving their various attributes and extended attributes: "tar --xattrs --xattrs-include='*' -cf - -C %s -p . | tar -p --xattrs --xattrs-include='*' -xf - -C %s" % (src, dst) Because this slowness is in xattr handling code we can't introduce new xattr consuming features (#9857, #9858) until the slow down is resolved — adding those two issues to the Blocks field. Okay, so, clear_unused_xattrs() is slow. It looks like we have two cases for did_unlink_file, and in some of them, we should be able to use an exact match (which would be way faster). I suspect that if I had two did_unlink_file, one of which specifies the device and inode, and can use the faster xattr clear, that'd work better. (In reply to comment #5) > Okay, so, clear_unused_xattrs() is slow. It looks like we have two cases for > did_unlink_file, and in some of them, we should be able to use an exact > match (which would be way faster). > > I suspect that if I had two did_unlink_file, one of which specifies the > device and inode, and can use the faster xattr clear, that'd work better. That sounds about right. I've been playing around with changes which might help and whilst I was uncertain as to the full detail behind the following comment in pdb_did_unlink_file() /* we have to clean everything because we don't know for sure the * device/inode... */ I decided to try a build with a dirty hack that tries to find the ino and dev of the unlinked file: https://github.com/incandescant/pseudo/commit/c50711e5d5ab85d4dd23e99565ac9ce1b56b743b With that patch applied a build which makes heavy use of xattr and I had to kill after >20hours is proceeding along and almost done after only a "few" hours. I'm guessing that the bulk of the problem comes from DID_UNLINK messages -- where we could have passed in the full message to did_unlink, and in that case we could do the faster/simpler xattr clean. The xattr sharing is sort of annoying, and I would much like to have a cleaner solution, but I haven't thought of one yet. Joshua, if slow delete handling is the root cause of the problem, then why does it affect the tar copy pipeline? That should only create files, not delete them. About tar itself: I found that bsdtar had much saner behavior (as in, "less system calls") than GNU tar when dealing with xattrs. It may be worthwhile to investigate using bsdtar instead of GNU tar. Another reason for that is that (presumably, haven't checked) you are using the host's GNU tar. That version may be too old to support xattrs properly, while a bsdtar-native compiled by bitbake is guaranteed to have it. (In reply to comment #7) > I'm guessing that the bulk of the problem comes from DID_UNLINK messages -- > where we could have passed in the full message to did_unlink, and in that > case we could do the faster/simpler xattr clean. Thanks Peter. Following this comment I wrote a patch to do just that, you can see it here (warning, transient URL): https://github.com/incandescant/pseudo/commit/ee9d967fb7114ba5a9d16f89977f720e74530d2d Running some test builds of Ostro OS using that patch I see significant speed improvements, i.e: ostro-image-swupd-1.0-r0: do_image: Elapsed time: 2880.87 seconds (In reply to comment #8) > Joshua, if slow delete handling is the root cause of the problem, then why > does it affect the tar copy pipeline? That should only create files, not > delete them. > > About tar itself: I found that bsdtar had much saner behavior (as in, "less > system calls") than GNU tar when dealing with xattrs. It may be worthwhile > to investigate using bsdtar instead of GNU tar. > > Another reason for that is that (presumably, haven't checked) you are using > the host's GNU tar. That version may be too old to support xattrs properly, > while a bsdtar-native compiled by bitbake is guaranteed to have it. Indeed, investigating bsdtar is high on my list as I've found GNU tar to be increasingly problematic as I've tried to include better xattr support on OE-Core (i.e. in sstate objects). I need to take a discussion to the OE-Arch list on this topic, I think. Peter came up with a more complete version of my change which is in pseudo master[1] and has been submitted for include in the OE-Core recipe as a backport[2]. 1. http://git.yoctoproject.org/clean/cgit.cgi/pseudo/commit/?id=0d9071f3090bbd7880558f3b488b236ac19b44fc 2. http://lists.openembedded.org/pipermail/openembedded-core/2016-August/124557.html |