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
=== modified file 'lib/lp/translations/scripts/message_sharing_migration.py'
--- lib/lp/translations/scripts/message_sharing_migration.py 2009-10-30 11:18:59 +0000
+++ lib/lp/translations/scripts/message_sharing_migration.py 2009-11-13 15:15:24 +0000
@@ -7,7 +7,6 @@
7 ]7 ]
88
99
10import gc
11import os10import os
1211
13from zope.component import getUtility12from zope.component import getUtility
@@ -291,15 +290,6 @@
291 if self.txn is None:290 if self.txn is None:
292 return291 return
293292
294 if self.commit_count % 100 == 0 or not intermediate:
295 freed = gc.collect()
296 objcount = len(gc.get_objects())
297 garbage = len(gc.garbage)
298 memsize = open("/proc/%s/statm" % os.getpid()).read().split()[5]
299 log.debug(
300 "Freed: %d. Object count: %d. Garbage: %d. Memory size: %s"
301 % (freed, objcount, garbage, memsize))
302
303 self.commit_count += 1293 self.commit_count += 1
304294
305 if intermediate and self.commit_count % 10 != 0:295 if intermediate and self.commit_count % 10 != 0: