Merge lp://staging/~mkanat/loggerhead/synchronize-lru_cache into lp://staging/loggerhead
Proposed by
Max Kanat-Alexander
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 418 | ||||
Proposed branch: | lp://staging/~mkanat/loggerhead/synchronize-lru_cache | ||||
Merge into: | lp://staging/loggerhead | ||||
Diff against target: |
51 lines (+7/-7) 1 file modified
loggerhead/history.py (+7/-7) |
||||
To merge this branch: | bzr merge lp://staging/~mkanat/loggerhead/synchronize-lru_cache | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matt Nordhoff | Approve | ||
Loggerhead Team | Pending | ||
Max Kanat-Alexander | Pending | ||
Review via email: mp+24651@code.staging.launchpad.net |
This proposal supersedes a proposal from 2010-04-23.
Description of the change
Fixes Bug #420738 by synchronizing all our access to lru_cache, which is not thread-safe.
In testing, I don't see any significant performance degradation under access from many different users accessing several different branches.
To post a comment you must log in.
Max,
Well done on tracking down the problem and thanks for the patch. Aren't threading problems fun? :-)
My main concern with the proposed change is that I'd prefer the Cache object to have the intelligence to Do The Right Thing wrt locking, rather than it being left up to the client to guard access to it. As it stands, we're deciding to use an LRU cache in apps/branch.py and paying the consequences through increased code complexity several layers deeper. What do you think about having a decorator class that provides the synchronized access? E.g. changing the cache creation line to be something like ...
graph_cache = ThreadSafeCache (bzrlib. lru_cache. LRUCache( 10))
and introducing ThreadSafeCache() as the layer with the RLock?
OTOH, this bug is critical and perhaps we ought to just land it as is, particularly as John is looking to rework the caching architecture Real Soon Now anyhow.
Any second opinions?