mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
indexedlog: allow defaulting to writing history to indexedlog
Summary:
An earlier diff, D21772132 (713fbeec24
), add an option to default hgcache data store
writes to indexedlog but it only did it for data, not history. Let's also do it
for history.
Reviewed By: quark-zju
Differential Revision: D22870952
fbshipit-source-id: 649361b2d946359b9fbdd038867e1058077bd101
This commit is contained in:
parent
6a2846b1ca
commit
b71124ad8c
@ -194,15 +194,9 @@ impl<'a> MetadataStoreBuilder<'a> {
|
||||
let mut historystore: UnionHgIdHistoryStore<Arc<dyn HgIdHistoryStore>> =
|
||||
UnionHgIdHistoryStore::new();
|
||||
|
||||
if self
|
||||
.config
|
||||
.get_or_default::<bool>("remotefilelog", "indexedloghistorystore")?
|
||||
{
|
||||
let shared_indexedloghistorystore = Arc::new(IndexedLogHgIdHistoryStore::new(
|
||||
get_indexedloghistorystore_path(&cache_path)?,
|
||||
)?);
|
||||
historystore.add(shared_indexedloghistorystore);
|
||||
}
|
||||
let shared_indexedloghistorystore = Arc::new(IndexedLogHgIdHistoryStore::new(
|
||||
get_indexedloghistorystore_path(&cache_path)?,
|
||||
)?);
|
||||
|
||||
// The shared store should precede the local one for 2 reasons:
|
||||
// - It is expected that the number of blobs and the number of requests satisfied by the
|
||||
@ -210,7 +204,19 @@ impl<'a> MetadataStoreBuilder<'a> {
|
||||
// - When pushing changes on a pushrebase server, the local linknode will become
|
||||
// incorrect, future fetches will put that change in the shared cache where the linknode
|
||||
// will be correct.
|
||||
historystore.add(shared_pack_store.clone());
|
||||
let primary: Arc<dyn HgIdMutableHistoryStore> = if self
|
||||
.config
|
||||
.get_or_default::<bool>("remotefilelog", "write-hgcache-to-indexedlog")?
|
||||
{
|
||||
// Put the indexedlog first, since recent data will have gone there.
|
||||
historystore.add(shared_indexedloghistorystore.clone());
|
||||
historystore.add(shared_pack_store.clone());
|
||||
shared_indexedloghistorystore
|
||||
} else {
|
||||
historystore.add(shared_pack_store.clone());
|
||||
historystore.add(shared_indexedloghistorystore.clone());
|
||||
shared_pack_store
|
||||
};
|
||||
|
||||
let local_mutablehistorystore: Option<Arc<dyn HgIdMutableHistoryStore>> =
|
||||
if let Some(local_path) = self.local_path {
|
||||
@ -241,25 +247,20 @@ impl<'a> MetadataStoreBuilder<'a> {
|
||||
// If data isn't found in the memcache store, once fetched from the remote store it
|
||||
// will be written to the local cache, and will populate the memcache store, so
|
||||
// other clients and future requests won't need to go to a network store.
|
||||
let memcachehistorystore = memcachestore
|
||||
.clone()
|
||||
.historystore(shared_pack_store.clone());
|
||||
let memcachehistorystore = memcachestore.clone().historystore(primary.clone());
|
||||
|
||||
let mut multiplexstore: MultiplexHgIdHistoryStore<
|
||||
Arc<dyn HgIdMutableHistoryStore>,
|
||||
> = MultiplexHgIdHistoryStore::new();
|
||||
multiplexstore.add_store(memcachestore);
|
||||
multiplexstore.add_store(shared_pack_store.clone());
|
||||
multiplexstore.add_store(primary.clone());
|
||||
|
||||
(
|
||||
Some(memcachehistorystore),
|
||||
Arc::new(multiplexstore) as Arc<dyn HgIdMutableHistoryStore>,
|
||||
)
|
||||
} else {
|
||||
(
|
||||
None,
|
||||
shared_pack_store.clone() as Arc<dyn HgIdMutableHistoryStore>,
|
||||
)
|
||||
(None, primary.clone() as Arc<dyn HgIdMutableHistoryStore>)
|
||||
};
|
||||
|
||||
let store = remotestore.historystore(shared_store);
|
||||
@ -279,7 +280,7 @@ impl<'a> MetadataStoreBuilder<'a> {
|
||||
None
|
||||
};
|
||||
|
||||
let shared_mutablehistorystore: Arc<dyn HgIdMutableHistoryStore> = shared_pack_store;
|
||||
let shared_mutablehistorystore: Arc<dyn HgIdMutableHistoryStore> = primary;
|
||||
|
||||
Ok(MetadataStore {
|
||||
historystore,
|
||||
|
@ -104,6 +104,10 @@
|
||||
$TESTTMP/hgcache/master/indexedlogdatastore/0/log
|
||||
$TESTTMP/hgcache/master/indexedlogdatastore/0/meta
|
||||
$TESTTMP/hgcache/master/indexedlogdatastore/latest
|
||||
$TESTTMP/hgcache/master/indexedloghistorystore/0/index2-node_and_path
|
||||
$TESTTMP/hgcache/master/indexedloghistorystore/0/log
|
||||
$TESTTMP/hgcache/master/indexedloghistorystore/0/meta
|
||||
$TESTTMP/hgcache/master/indexedloghistorystore/latest
|
||||
$TESTTMP/hgcache/master/lfs/blobs/0/index2-sha256
|
||||
$TESTTMP/hgcache/master/lfs/blobs/0/log
|
||||
$TESTTMP/hgcache/master/lfs/blobs/0/meta
|
||||
|
@ -74,8 +74,8 @@ Test that we can repack packs into indexedlog
|
||||
-rw-rw-r-- 25 index2-node
|
||||
-rw-rw-r-- 108 log
|
||||
-rw-rw-r-- * meta (glob)
|
||||
$ ls $CACHEDIR/master/packs/ | grep datapack
|
||||
[1]
|
||||
$ ls $CACHEDIR/master/packs/ | grep pack
|
||||
repacklock
|
||||
|
||||
# Verify new fetches go to the indexedlog
|
||||
$ clearcache
|
||||
@ -85,7 +85,7 @@ Test that we can repack packs into indexedlog
|
||||
-rw-rw-r-- 25 index2-node
|
||||
-rw-rw-r-- 108 log
|
||||
-rw-rw-r-- * meta (glob)
|
||||
$ ls $CACHEDIR/master/packs/ | grep datapack
|
||||
$ ls $CACHEDIR/master/packs/ | grep pack
|
||||
[1]
|
||||
$ hg cat -r tip x
|
||||
x
|
||||
|
Loading…
Reference in New Issue
Block a user