Gentoo Archives: gentoo-dev

From: Richard Yao <ryao@g.o>
To: Neil Cahill <ncahill_alt@×××××.com>
Cc: "gentoo-dev@l.g.o" <gentoo-dev@l.g.o>, gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-dev] Patch to sys-apps/portage-2.2.7 giving 2% performance increase
Date: Fri, 18 Oct 2013 16:57:21
Message-Id: 5261682C.6050902@gentoo.org
In Reply to: [gentoo-dev] Patch to sys-apps/portage-2.2.7 giving 2% performance increase by Neil Cahill
1 Dear Ned,
2
3 This should have been sent to gentoo-portage-dev@ rather than
4 gentoo-dev@, but that is easy to rectify. I am CCing gentoo-portage-dev@.
5
6 That being said, nice job. I think everyone on gentoo-dev@ will
7 appreciate your work on this.
8
9 Yours truly,
10 Richard Yao
11
12 On 10/18/2013 12:46 PM, Neil Cahill wrote:
13 > I profiled an execution of "emerge -pv sed" to look for easy ways to increase the speed of that command. The following 2-line patch gives a 2% reduced run time. The profile showed that regex matching accounts for 8.3% of the run time, so these updated regular expressions are at least 25% quicker. I hoped it would help more but it should all add up.
14 >
15 > As I get more time I may look to submit other small improvements.
16 >
17 > As for how the patch works, the version number part of a package name has many options so that part of the regular expression is time consuming. It was advantageous to use an assertion to visit that part of the expression less often. Python since 2.4 supports what I've used so this should work on all current versions.
18 >
19 > Thank you.
20 > Neil Cahill.
21 >
22 > ### patch ###
23 > --- pym/portage/versions.py 2013-09-23 21:59:21.000000000 +0100
24 > +++ pym/portage/versions.py 2013-10-08 14:48:11.178441337 +0100
25 > @@ -45,8 +45,8 @@
26 > # It must not begin with a hyphen,
27 > # and must not end in a hyphen followed by one or more digits.
28 > _pkg = {
29 > - "dots_disallowed_in_PN": r'[\w+][\w+-]*?',
30 > - "dots_allowed_in_PN": r'[\w+][\w+.-]*?',
31 > + "dots_disallowed_in_PN": r'[\w+][\w+-]*?(?![\w+])',
32 > + "dots_allowed_in_PN": r'[\w+][\w+.-]*?(?![\w+.])',
33 > }
34 >
35 > _v = r'(cvs\.)?(\d+)((\.\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\d*)*)'
36 > ### end patch ###
37 >

Attachments

File name MIME type
signature.asc application/pgp-signature