Merge lp:~vila/bzr/948339-config-caching into lp:bzr
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Martin Packman on 2012-03-16 | ||||
| Approved revision: | 6501 | ||||
| Merged at revision: | 6512 | ||||
| Proposed branch: | lp:~vila/bzr/948339-config-caching | ||||
| Merge into: | lp:bzr | ||||
| Diff against target: |
242 lines (+61/-24) 8 files modified
bzrlib/branch.py (+3/-3) bzrlib/config.py (+14/-11) bzrlib/plugins/changelog_merge/tests/test_changelog_merge.py (+4/-1) bzrlib/tests/test_branch.py (+15/-9) bzrlib/tests/test_config.py (+14/-0) bzrlib/tests/test_merge_core.py (+1/-0) doc/developers/configuration.txt (+7/-0) doc/en/release-notes/bzr-2.6.txt (+3/-0) |
||||
| To merge this branch: | bzr merge lp:~vila/bzr/948339-config-caching | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Martin Packman (community) | 2012-03-13 | Approve on 2012-03-16 | |
|
Review via email:
|
|||
Commit Message
Properly share mutable config sections and save the branch config only during the final unlock
Description of the Change
This fix two bugs in the config stack API:
1) the branch config was saved (if changes have been made) for every
unlock(). This now happens only for the highest level lock.
2) mutable sections weren't properly shared
On top of this proposal I did two experiments to purge the cached config on
unlock():
1) Define a _clear_
self.
Chaos ensued, more than 130 tests failed. _clear_
used to unload the config store because it's used in specific ways that go
beyond what can be deduced from its name (see last_revision_
_set_revision_
More concretely, _clear_
method so it can't be used here.
2) calls self.conf_
All test passed *but* using -Econfig_stats, we went, for the whole test
suite from config.load : 54487 to config.load : 114282, roughly doubling
branch.conf accesses. This is caused by all the methods decorated with
@needs_read_lock trigerring a config purge which of course goes against the
aim of reducing the IOs.
Wrong idea IMHO.
So unlocked branch objects will keep their config cached specifically to
cover the use case of unlocked branch objects.
Fixing this requires switching to a model where we never use unlocked
branches which in itself is a really big change which may be valuable but
which has so many fallouts that I don't think we want to tackle it for now.
| Vincent Ladeuil (vila) wrote : | # |
> Summarising from discussion on IRC yesterday,
>
> The lock count change doesn't seem to be directly asserted by
> test_set_
> the fix, as does test_set_
> manner, so that's fine.
Yeah, the more I think about remarks like this (or one I do myself during reviews), the more I believe I should keep more detailed notes while working on the fix and have a way to mention the narrative in the cover letter... You rightly understand how I proceeded, well done Watson ;) Err, Sherlock ? ;-p
>
> Flipping the expectedFailure assertions where the behaviour isn't worth fixing
> is a little odd,
It's more than 'not worth fixing', it's really that trying to maintain compatibility between the two APIs can't be done while still reducing the IOs. The old API *really* relies in many ways on the fact that each and every change is saved to disk. No matter how you use the old API, you will never miss a change: from different objects in the same process, from different processes, everything works. This came with a price: read the config file for each and every option. Read *and* write the config file for each and every change.
The new implementation already dropped some possible optimisations to ease the transition and is safe (AFAIK) to mix with the old one *as long* as one API only is used for a given option.
So dropping the IO reduction for compatibility sake ? I say no. Some migrations will be harder than others but well, they'll have to happen, so the sooner the better.
> though the added reasoning is nice. Ideally, it would live
> not here but somewhere that people trying to use config and running into
> problems might actually find.
Should I refer to these tests in doc/developers/
>
> The added test_mutable_
> though I find the list->dict fixes slightly mysterious without working out
> more about the config details, I'm happy with the change.
Ok. I'll add a comment to better explain why it's important that MutableSection should stay unique to be truly shared in the __init__ method then, would that have helped ?
| Martin Packman (gz) wrote : | # |
> So dropping the IO reduction for compatibility sake ? I say no. Some
> migrations will be harder than others but well, they'll have to happen, so the
> sooner the better.
>
> > though the added reasoning is nice. Ideally, it would live
> > not here but somewhere that people trying to use config and running into
> > problems might actually find.
>
> Should I refer to these tests in doc/developers/
Not the tests, but something that would have helped Aaron when he was wondering why the things these tests exercise don't work would be good. A general migration thing with warnings about the pitfalls would be nice, currently that doc just lists some some ai changes without further advice.
> Ok. I'll add a comment to better explain why it's important that
> MutableSection should stay unique to be truly shared in the __init__ method
> then, would that have helped ?
Maybe a little, my issue was mostly that I'm not familiar with what the code is doing.
- 6502. By Vincent Ladeuil on 2012-03-28
-
Clarify the dict usage to share dirty sections.
| Vincent Ladeuil (vila) wrote : | # |
sent to pqm by email

Summarising from discussion on IRC yesterday,
The lock count change doesn't seem to be directly asserted by test_set_ delays_ write. Checking now though the test does in fact fail without the fix, as does test_set_ from_config_ stack_get_ from_config in a similar manner, so that's fine.
Flipping the expectedFailure assertions where the behaviour isn't worth fixing is a little odd, though the added reasoning is nice. Ideally, it would live not here but somewhere that people trying to use config and running into problems might actually find.
The added test_mutable_ section_ shared is nice and easy to follow, so even though I find the list->dict fixes slightly mysterious without working out more about the config details, I'm happy with the change.