Edgewall Software
Modify

Opened 16 years ago

Closed 15 years ago

Last modified 15 years ago

#7518 closed enhancement (fixed)

Cleanup Trac Imports

Reported by: cg@… Owned by: Remy Blank
Priority: low Milestone: 0.12
Component: general Version: 0.12dev
Severity: minor Keywords: patch
Cc: cg@…, info@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Since I'm using Trac very much I have a big problem with it. It just leaks memory, a gc.collect() collects more than 10.000 objects after some requests.

I have just created a patch file that cleans up unused imports, star-imports are also deleted ('cause they clutter the namespace). Maybe that's a startingpoint to cleanup some things and let it leak less memory.

Attachments (2)

imports.patch (33.4 KB ) - added by cg@… 16 years ago.
The patch file that fixes some import-errors
imports.2.patch (21.4 KB ) - added by Christopher Grebs <cg@…> 16 years ago.
New patch (without * imports replaced)

Download all attachments as: .zip

Change History (21)

by cg@…, 16 years ago

Attachment: imports.patch added

The patch file that fixes some import-errors

comment:1 by Christopher Grebs <cg@…>, 16 years ago

Oh, by the way. The patch was created with the latest changeset included ([7455])

I'm still not sure if it really helps to minimize memleak but it cleans it up anyway :D

comment:2 by Christopher Grebs <cg@…>, 16 years ago

Cc: cg@… added

in reply to:  1 comment:3 by Christopher Grebs <cg@…>, 16 years ago

Replying to Christopher Grebs <cg@…>:

Oh, by the way. The patch was created with the latest changeset included ([7455])

I'm still not sure if it really helps to minimize memleak but it cleans it up anyway :D

argh, wrong link. Anyway the latest trunk (not 0.11 stable branch) is the base.

comment:4 by Matthew Good, 16 years ago

Thanks for looking at the unused imports. Getting rid of some of those helps keep the code clean, but is not going to have a significant impact on memory usage. Imported modules are always referred to by sys.modules, so they will never get garbage collected (this is intentional to make sure modules are only executed the first time you import them).

However, I think most of the "import *"s are intentional. Trac uses __all__ extensively to ensure that "import *" only imports names intentionally exposed by that module and does not pollute the namespace. This is also convenient for commonly used modules like "trac.core" so that you don't have to remember to add each of these as you start to use them.

Can you re-submit a patch that does not include the "import *" expansions?

by Christopher Grebs <cg@…>, 16 years ago

Attachment: imports.2.patch added

New patch (without * imports replaced)

comment:5 by Christopher Grebs <cg@…>, 16 years ago

I just added the new patch – this should work… thank's for answer my ticket. Regarding memory-leaking: I learned that python2.4 can't free reserved memory and I think that's the most depressing thingy…

comment:6 by Remy Blank, 16 years ago

Keywords: patch added
Milestone: 0.13

Some cleanup would indeed be needed.

comment:7 by Christian Boos, 16 years ago

Milestone: 0.130.12
Priority: highlow
Severity: majorminor
Type: taskenhancement

Christopher, any chance you could update the patch to current trunk?

comment:8 by Christopher Grebs <cg@…>, 16 years ago

Hey,

I think this should be no problem. I think I can find some minutes tomorrow or so. Stay tuned :-)

comment:9 by Thijs Triemstra <info@…>, 15 years ago

Cc: info@… added

comment:10 by Remy Blank, 15 years ago

Owner: set to Remy Blank

comment:11 by Remy Blank, 15 years ago

What would really be useful is a script that collects all imports and finds which symbols don't appear anywhere else in the module. Maybe I'll give it a shot.

in reply to:  12 comment:13 by Remy Blank, 15 years ago

Replying to cboos:

google:pylint or google:pychecker?

Sure, more efficient, but not as fun :-) I knew about pylint, but haven't used it so far. Good opportunity to find out!

comment:15 by Remy Blank, 15 years ago

I have managed to get pylint working with PyDev, and that thing is pretty amazing! Configuration takes a bit of time, but it does catch many "cosmetic" errors (and even less cosmetic ones). Patch coming shortly (and hopefully it won't break all the patches in your queue).

comment:16 by Christian Boos, 15 years ago

What would you think about an even more drastic clean-up, which would be to import modules only, not the objects defined in those modules.

This would get rid of (most) of the import maintenance trouble, make the import lists much smaller, and clearly show which names are coming from which module. This is the style followed by Mercurial, Django, at Google

in reply to:  16 comment:17 by Remy Blank, 15 years ago

Replying to cboos:

What would you think about an even more drastic clean-up, which would be to import modules only, not the objects defined in those modules.

My first reaction was: no, please no! Having to prefix every class reference and every function call with a module name sounds like a pain in the backside, and IMO hurts readability.

But thinking about it, there are probably not that many class references, and function calls are also relatively rare compared to method calls. So it's probably not as bad as I initially thought.

Now, if we want to stay on-schedule for 0.12, I wouldn't do that now. Moreover, this is a purely cosmetic issue, so it will take time for no added value to the user.

So, -1 for 0.12, and a small -0 for next-major-0.1X.

comment:18 by Remy Blank, 15 years ago

Resolution: fixed
Status: newclosed

A thorough cleanup (using pylint) has been committed in [8734].

comment:19 by Remy Blank, 15 years ago

And some additional cleanup on multirepos in [8736].

… my… head… hurts…

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.