Merge lp:~vila/bzr/832042-shared-stores into lp:bzr
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Vincent Ladeuil | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 6554 | ||||
Proposed branch: | lp:~vila/bzr/832042-shared-stores | ||||
Merge into: | lp:bzr | ||||
Diff against target: |
489 lines (+141/-56) 13 files modified
bzrlib/config.py (+62/-9) bzrlib/library_state.py (+6/-0) bzrlib/lockdir.py (+1/-1) bzrlib/plugins/launchpad/test_register.py (+4/-0) bzrlib/remote.py (+2/-2) bzrlib/tests/__init__.py (+35/-29) bzrlib/tests/blackbox/test_init.py (+4/-2) bzrlib/tests/blackbox/test_serve.py (+2/-3) bzrlib/tests/test_config.py (+9/-0) bzrlib/tests/test_debug.py (+7/-4) bzrlib/tests/test_lockdir.py (+1/-1) bzrlib/tests/test_ui.py (+1/-2) doc/en/release-notes/bzr-2.6.txt (+7/-3) |
||||
To merge this branch: | bzr merge lp:~vila/bzr/832042-shared-stores | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Packman (community) | Approve | ||
Review via email: mp+118110@code.launchpad.net |
Commit message
Share and cache local config files
Description of the change
This fixes bug #832042 by sharing and caching local config files, opening
the doors wide for adding more config options or files.
The implementation is the simplest one: the library state gains a dict
attribute for all used stores.
A fallback is needed for scripts that never call bzrlib.intialize() until we
fix the bug(s) about always requiring a library state object to be available
whatever script is used and pass these state objects around in the code base
(repo/ranch/wts should know about which state they are used with (somehow
like transports need to be shared)).
The fallback is a bit ugly, but not much than missing the library state :)
Compared to the corresponding change for branches config file, this one if
far lighter and only a couple of tests needed to be fixed. Even there the
use case is at the limit to what is expected to be supported: communication
with a subprocess (for which config files are a bad medium anyway).
To describe impact, numbers speak better than words, so, with the following
patch:
=== modified file 'bzrlib/lockdir.py'
--- bzrlib/lockdir.py 2011-12-19 13:23:58 +0000
+++ bzrlib/lockdir.py 2012-08-02 08:52:49 +0000
@@ -858,6 +858,6 @@
as it gives some clue who the user is.
"""
try:
- return config.
+ return config.
except errors.NoWhoami:
return osutils.
Running the full test suite with -Econfig_stats allows going from:
config.load : 53265
config.save : 4005
config.get : 453640
config.set : 4667
config.remove : 26
old_config.load : 294868
old_config.save : 608
old_config.get : 166067
old_config.set : 475
old_config.remove: 6
to
config.load : 53342
config.save : 4005
config.get : 627394
config.set : 4667
config.remove : 26
old_config.load : 124371
old_config.save : 608
old_config.get : 166067
old_config.set : 475
old_config.remove: 6
I.e. old_config.load goes from 294,868 to 124,371 (-170,497) whereas
config.load goes from 53,265 to 53,342 (+77), or in marketing speak a
221,424% improvement !11!! ;)
More seriously, in this specific case, most of the tests rely on BZR_EMAIL
anyway so what the new design really provides is *avoiding* the IO since the
env var takes precedence (whereas the old design would read the file anyway
*before* looking at the env var). This explains why config.get goes from
453640 to 627394 (+ 173,754) whereas old_config.get stays stable and
config.load only goes up moderately.
So overall, the first revno I started collected statistics for is 5981:
config.load : 296
config.save : 106
config.get : 82
config.set : 52
config.remove : 8
old_config.load : 1002308
old_config.save : 5018
old_config.get : 383768
old_config.set : 4873
old_config.remove: 14
the significant ratio being old_config.get / old_config.load: 0.38
and with this proposal (with still some old config uses) we are at:
config.load : 53310
config.save : 4006
config.get : 627375
config.set : 4686
config.remove : 26
old_config.load : 124352
old_config.save : 588
old_config.get : 166068
old_config.set : 456
old_config.remove: 6
config.get / config.load ratio: 11.76
Since there were a bunch of changes the numbers cannot be compared directly
bu the trend is obvious a single IO for multiple config options instead of
several IOs for a single option. In proper English: feel free to use more
options and config files, they are basically free once you use at least one
(which all bzr commands do).
This patch also provides fresh shared stores for tests or they'll use the
fallback which means they aren't saved until selftest exits (which make no
test (well almost) fail but is still a kind of leak).
On a related note, many tests use TestCaseWithMem
branchbuilder relying on the limited ability to handle a tree/branch/repo in
a MemoryTransport, including locking. Locking use the 'email' config option
and as such looks for bazaar.conf... which doesn't exist for a
MemoryTransport... which is fine since we have a sane default and bzr copes
with non-existing config files. Pfew. I wrongly chased these tests as
potential culprits for not using TestCaseInTempDir before realizing they
were indeed allowed to run without an existing bazaar.conf. I thought it was
worth mentioning for those following from home. This is why _shared_stores
is overriden during setup at the TestCaseWithMem
of TestCaseInTempDir.
I moved setUp at the beginning of the class for TestCaseWithMem
and TestCaseWithTra
(that's the usual pattern in the rest of the code base anyway).
Also:
- split the eager test in bt.test_debug,
- use proper unique urls for remote config files (for both better error
messages and sharing),
Next possible steps are to:
- remove (finally !) BranchOnlyStack since the cheap optimization that
triggered its need is not worth the code duplication and complexity
anymore,
- properly test the library state stuff (http://
of the fallback.
Can I have a review ? Pretty please ?