1 |
On Saturday 17 September 2005 02:32, Alec Warner wrote: |
2 |
> Jason Stubbs wrote: |
3 |
> > On Saturday 17 September 2005 01:59, Paul Varner wrote: |
4 |
> >>http://bugs.gentoo.org/show_bug.cgi?id=90680 |
5 |
> >> |
6 |
> >>Author: Paul Varner |
7 |
> >> |
8 |
> >>The current implementation of gentoolkit creates a portage.config |
9 |
> >> object for every package object that it creates. While this is the |
10 |
> >> correct thing to do from an object-oriented programming point of |
11 |
> >> view, this implementation consumes an excessive amount of memory and |
12 |
> >> CPU. The proposed patch changes the portage.config object for each |
13 |
> >> package object to point to a single global object. |
14 |
> >> |
15 |
> >>If no one sees any serious issues with the patch, I will be placing |
16 |
> >> it into gentoolkit. |
17 |
> > |
18 |
> > I tried doing this once before locally, but found some issue with it. |
19 |
> > Unfortunately, I can't remember what that issue was. If you are |
20 |
> > calling setcpv() for every call to the package object that utilizes |
21 |
> > the config object and no utilizing packages (in gentoolkit or |
22 |
> > otherwise) are utilizing threading, it should theoretically be okay. |
23 |
> > Actually, I think it was the threading issue that delayed the fix. |
24 |
> |
25 |
> I can't remember the model for this, but there is some logic along the |
26 |
> lines of intercepting config object writes with setattr and then |
27 |
> cloning the config object. That way if the config is read-only only 1 |
28 |
> is instantiated, but if you attempt to modify it, the config would |
29 |
> clone itself, then proceed with the modification and return the cloned |
30 |
> copy. Not sure how easy that would be to implement, perhaps some sort |
31 |
> of wrapper class? |
32 |
|
33 |
To share such an object the right way from an OO perspective would require |
34 |
to pass the object along at package object instanciation. I doubt though |
35 |
that the config object should be modified. But if it must in some cases a |
36 |
lazy copy scheme is probably most efficient. You'd probably have the |
37 |
editing code do something like: |
38 |
this->editableConfig()->changeAttribute(...) |
39 |
|
40 |
Where the editableConfig function checks whether a copy has been made, if |
41 |
so, it will just use that copy, else it will make a copy and return it. |
42 |
|
43 |
Paul |
44 |
|
45 |
|
46 |
-- |
47 |
Paul de Vrieze |
48 |
Gentoo Developer |
49 |
Mail: pauldv@g.o |
50 |
Homepage: http://www.devrieze.net |