Merge lp:~jtv/launchpad/message-sharing-rearrange-commits into lp:launchpad

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~jtv/launchpad/message-sharing-rearrange-commits
Merge into: lp:launchpad
Diff against target: 27 lines (+0/-10)
1 file modified
lib/lp/translations/scripts/message_sharing_migration.py (+0/-10)
To merge this branch: bzr merge lp:~jtv/launchpad/message-sharing-rearrange-commits
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+14342@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

= Rearranging gc and commits in message-sharing migration =

Memory usage is still an issue in the message-sharing migration script. It commits and gc's periodically, but in phase 3 we still see increasing object counts.

This script is a minor tweak to give us better debug output: it makes the explicit garbage-collection runs happen just after a commit, when there's an absolute minimum number of objects still pinned in memory by the ongoing transaction.

There's no functional impact, but the change makes sense even outside the debugging context because it's... well, it's... uh, it's just better.

No lint, no tests (well, run {{{bin/test -vv -t message.sharing}}} if you feel like it) and no miracle cures for this one.

Jeroen

Revision history for this message
Stuart Bishop (stub) wrote :

Outside of debugging, we won't want the explicit garbage collection calls at all.

I agree this makes sense for debugging.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/scripts/message_sharing_migration.py'
2--- lib/lp/translations/scripts/message_sharing_migration.py 2009-10-30 11:18:59 +0000
3+++ lib/lp/translations/scripts/message_sharing_migration.py 2009-11-13 15:15:24 +0000
4@@ -7,7 +7,6 @@
5 ]
6
7
8-import gc
9 import os
10
11 from zope.component import getUtility
12@@ -291,15 +290,6 @@
13 if self.txn is None:
14 return
15
16- if self.commit_count % 100 == 0 or not intermediate:
17- freed = gc.collect()
18- objcount = len(gc.get_objects())
19- garbage = len(gc.garbage)
20- memsize = open("/proc/%s/statm" % os.getpid()).read().split()[5]
21- log.debug(
22- "Freed: %d. Object count: %d. Garbage: %d. Memory size: %s"
23- % (freed, objcount, garbage, memsize))
24-
25 self.commit_count += 1
26
27 if intermediate and self.commit_count % 10 != 0: