Date: Wed, 26 Mar 2008 17:18:29 +0100 From: Pav Lucistnik <pav@FreeBSD.org> To: freebsd-ports@FreeBSD.org Cc: rdivacky@FreeBSD.org, soralx@cydem.org Subject: [patch] pkg_delete(1) speedup Message-ID: <1206548309.78560.69.camel@pav.hide.vol.cz>
next in thread | raw e-mail | index | archive | help
--=-vC/DqVTgUoEBp98Zlv9h Content-Type: multipart/mixed; boundary="=-gy6w4Z4DMzOlLo/sf16H" --=-gy6w4Z4DMzOlLo/sf16H Content-Type: text/plain Content-Transfer-Encoding: quoted-printable You might have noticed a thread on the mailing list called "ports system woes". The submitter pointed out an inefficiency in pkg_delete routine, that parses the whole /var/db/pkg over and over again for every dependency of a package being removed. Attached is a patch by rdivacky that implements the idea of looking up all the values in a single pass over /var/db/pkg content. A trivial benchmark, wall times: port with two dependencies (comms/obexapp) before 0.083s after 0.049s port with 172 dependencies (graphics/agave) before 8.404s 8.955s 11.734s after 2.816s 2.690s 3.195s The patch is not WARNS clean, that needs to be fixed. And I'd like a review by someone with src commit bit. --=20 Pav Lucistnik <pav@oook.cz> <pav@FreeBSD.org> 42.7 percent of all statistics are made up on the spot. --=-gy6w4Z4DMzOlLo/sf16H Content-Disposition: attachment; filename=pkg_delete.patch Content-Type: text/x-patch; name=pkg_delete.patch; charset=ISO8859-2 Content-Transfer-Encoding: base64 SW5kZXg6IGRlbGV0ZS9wZXJmb3JtLmMNCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NClJDUyBmaWxlOiAvaG9tZS9uY3Zz L3NyYy91c3Iuc2Jpbi9wa2dfaW5zdGFsbC9kZWxldGUvcGVyZm9ybS5jLHYNCnJldHJpZXZpbmcg cmV2aXNpb24gMS40MQ0KZGlmZiAtYSAtdSAtcjEuNDEgcGVyZm9ybS5jDQotLS0gZGVsZXRlL3Bl cmZvcm0uYwkyOSBKdW4gMjAwNCAxOTowNjo0MSAtMDAwMAkxLjQxDQorK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TgUoEBp98Zlv9h Content-Type: application/pgp-signature; name=signature.asc Content-Description: Toto je =?UTF-8?Q?digit=C3=A1ln=C4=9B?= =?ISO-8859-1?Q?_podepsan=E1?= =?UTF-8?Q?_=C4=8D=C3=A1st?= =?ISO-8859-1?Q?_zpr=E1vy?= -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (FreeBSD) iEYEABECAAYFAkfqd1UACgkQntdYP8FOsoIrOwCfextuhs/04NJx/c1Pp8zJ/Ueb pzQAoJTDF3DtyR4dBOHT4Mw6EmgrmM0T =cYb2 -----END PGP SIGNATURE----- --=-vC/DqVTgUoEBp98Zlv9h--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1206548309.78560.69.camel>