Skip to content

Commit 7d821c4

Browse files
muirdmmeta-codesync[bot]
authored andcommitted
backingstore: avoid constantly reloading sl repo
Summary: When there `make_matcher` callback returned `None` we were callign `make_matcher` every time through the loop. The callback loads the Sapling Repo object, which is too heavy to do every time. Fix by tweaking things so `make_matcher` is only invoked when the current commit changes. Reviewed By: Alramech Differential Revision: D88696778 fbshipit-source-id: 1dbf987ded3aae608b9d3cbc68e9cf0e5f5dc028
1 parent 4e93956 commit 7d821c4

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

eden/scm/lib/backingstore/src/prefetch.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,7 @@ pub(crate) fn prefetch_manager(
138138
}
139139
};
140140

141-
if prev_commit_id
142-
.as_ref()
143-
.is_some_and(|id| *id != current_commit_id)
144-
{
141+
if prev_commit_id.as_ref() != Some(&current_commit_id) {
145142
tracing::info!(
146143
?prev_commit_id,
147144
?current_commit_id,
@@ -153,20 +150,17 @@ pub(crate) fn prefetch_manager(
153150
handled_prefetches.clear();
154151
batch_dir_prefetches.clear();
155152
current_manifest.take();
156-
sparse_matcher.take();
157-
}
158153

159-
prev_commit_id = Some(current_commit_id);
160-
161-
// Reevaluate the sparse matcher since it can change across commits
162-
if sparse_matcher.is_none() {
154+
// Reevaluate the sparse matcher since it can change across commits
163155
sparse_matcher = match (make_matcher)(repo_root.clone()) {
164156
Ok(m) => m,
165157
Err(e) => {
166158
tracing::error!("fetching sparse matcher for workingcopy: {:?}", e);
167159
continue;
168160
}
169161
};
162+
163+
prev_commit_id = Some(current_commit_id);
170164
}
171165

172166
// Currently active walks according to the walk detector. Note that it will only report
@@ -1070,7 +1064,7 @@ mod test {
10701064

10711065
// Wait for prefetch to finish.
10721066
for _ in 0..10 {
1073-
if store.key_fetch_count() < 4 {
1067+
if store.key_fetch_count() < 7 {
10741068
std::thread::sleep(Duration::from_millis(1));
10751069
}
10761070
}

0 commit comments

Comments
 (0)