Merge lp:~mbp/bzr/lazy-commands into lp:bzr

Proposed by Martin Pool
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mbp/bzr/lazy-commands
Merge into: lp:bzr
Diff against target: 134 lines (+61/-9)
5 files modified
.bzrignore (+1/-0)
NEWS (+34/-0)
bzrlib/builtins.py (+18/-5)
bzrlib/commands.py (+1/-4)
bzrlib/tests/test_import_tariff.py (+7/-0)
To merge this branch: bzr merge lp:~mbp/bzr/lazy-commands
Reviewer Review Type Date Requested Status
Andrew Bennetts Approve
Review via email: mp+22590@code.launchpad.net

Commit message

(mbp) lazy-load some more commands

Description of the change

This makes some other commands not inline within builtins.py be lazy-loaded.

John previously raised in <https://code.edge.launchpad.net/~mbp/bzr/lazy-commands/+merge/21910> the issue of testing handling of aliases etc for lazy commands. I had a look in test_commands and there is already some coverage of that, enough that I don't feel like looking for trouble.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

This does seem to slightly cut the time to run 'bzr st' with cold caches in a bzr tree on my machine 'grace' from about 1.772-1.892s down to 1.568-1.716s.

Revision history for this message
Andrew Bennetts (spiv) wrote :

Looks good! Possibly worth a NEWS entry.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2009-10-07 15:48:32 +0000
+++ .bzrignore 2010-04-01 08:23:23 +0000
@@ -67,3 +67,4 @@
67bzrlib/_*.so67bzrlib/_*.so
68bzrlib/_*.pyd68bzrlib/_*.pyd
69./.ccache69./.ccache
70.testrepository
7071
=== modified file 'NEWS'
--- NEWS 2010-04-01 00:40:31 +0000
+++ NEWS 2010-04-01 08:23:23 +0000
@@ -5,6 +5,40 @@
5.. contents:: List of Releases5.. contents:: List of Releases
6 :depth: 16 :depth: 1
77
8bzr 2.2b2
9#########
10
11:2.2b2: NOT RELEASED YET
12
13Compatibility Breaks
14********************
15
16New Features
17************
18
19Bug Fixes
20*********
21
22Improvements
23************
24
25* Less code is loaded at startup. (Cold-cache start time is about 10-20%
26 less.)
27 (Martin Pool, #553017)
28
29Documentation
30*************
31
32API Changes
33***********
34
35Internals
36*********
37
38Testing
39*******
40
41
8bzr 2.2.0b142bzr 2.2.0b1
9###########43###########
1044
1145
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 2010-03-29 06:37:23 +0000
+++ bzrlib/builtins.py 2010-04-01 08:23:23 +0000
@@ -60,7 +60,11 @@
60from bzrlib.workingtree import WorkingTree60from bzrlib.workingtree import WorkingTree
61""")61""")
6262
63from bzrlib.commands import Command, display_command63from bzrlib.commands import (
64 Command,
65 builtin_command_registry,
66 display_command,
67 )
64from bzrlib.option import (68from bzrlib.option import (
65 ListOption,69 ListOption,
66 Option,70 Option,
@@ -4062,6 +4066,7 @@
40624066
4063 def run(self, file_list=None, merge_type=None, show_base=False,4067 def run(self, file_list=None, merge_type=None, show_base=False,
4064 reprocess=False):4068 reprocess=False):
4069 from bzrlib.conflicts import restore
4065 if merge_type is None:4070 if merge_type is None:
4066 merge_type = _mod_merge.Merge3Merger4071 merge_type = _mod_merge.Merge3Merger
4067 tree, file_list = tree_files(file_list)4072 tree, file_list = tree_files(file_list)
@@ -5975,7 +5980,15 @@
5975 self.outf.write('%s %s\n' % (path, location))5980 self.outf.write('%s %s\n' % (path, location))
59765981
59775982
5978from bzrlib.cmd_version_info import cmd_version_info5983def _register_lazy_builtins():
5979from bzrlib.conflicts import cmd_resolve, cmd_conflicts, restore5984 # register lazy builtins from other modules; called at startup and should
5980from bzrlib.foreign import cmd_dpush5985 # be only called once.
5981from bzrlib.sign_my_commits import cmd_sign_my_commits5986 for (name, aliases, module_name) in [
5987 ('cmd_bundle_info', [], 'bzrlib.bundle.commands'),
5988 ('cmd_dpush', [], 'bzrlib.foreign'),
5989 ('cmd_version_info', [], 'bzrlib.cmd_version_info'),
5990 ('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
5991 ('cmd_conflicts', [], 'bzrlib.conflicts'),
5992 ('cmd_sign_my_commits', [], 'bzrlib.sign_my_commits'),
5993 ]:
5994 builtin_command_registry.register_lazy(name, aliases, module_name)
59825995
=== modified file 'bzrlib/commands.py'
--- bzrlib/commands.py 2010-03-25 06:52:38 +0000
+++ bzrlib/commands.py 2010-04-01 08:23:23 +0000
@@ -182,10 +182,7 @@
182 import bzrlib.builtins182 import bzrlib.builtins
183 for cmd_class in _scan_module_for_commands(bzrlib.builtins).values():183 for cmd_class in _scan_module_for_commands(bzrlib.builtins).values():
184 builtin_command_registry.register(cmd_class)184 builtin_command_registry.register(cmd_class)
185 # lazy builtins185 bzrlib.builtins._register_lazy_builtins()
186 builtin_command_registry.register_lazy('cmd_bundle_info',
187 [],
188 'bzrlib.bundle.commands')
189186
190187
191def _scan_module_for_commands(module):188def _scan_module_for_commands(module):
192189
=== modified file 'bzrlib/tests/test_import_tariff.py'
--- bzrlib/tests/test_import_tariff.py 2010-03-23 06:03:14 +0000
+++ bzrlib/tests/test_import_tariff.py 2010-04-01 08:23:23 +0000
@@ -91,8 +91,15 @@
91 self.make_branch_and_tree('.')91 self.make_branch_and_tree('.')
92 self.run_command_check_imports(['st'], [92 self.run_command_check_imports(['st'], [
93 'bzrlib.bundle.commands',93 'bzrlib.bundle.commands',
94 'bzrlib.cmd_version_info',
95 'bzrlib.foreign',
94 'bzrlib.remote',96 'bzrlib.remote',
97 'bzrlib.sign_my_commits',
95 'bzrlib.smart',98 'bzrlib.smart',
96 'smtplib',99 'smtplib',
97 'tarfile',100 'tarfile',
98 ])101 ])
102 # TODO: similar test for repository-only operations, checking we avoid
103 # loading wt-specific stuff
104 #
105 # See https://bugs.edge.launchpad.net/bzr/+bug/553017