Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a concurrent tree-diffing algo #2517

Merged
merged 6 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cli/examples/custom-backend/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ impl Backend for JitBackend {
self.inner.empty_tree_id()
}

fn concurrency(&self) -> usize {
1
}

async fn read_file(&self, path: &RepoPath, id: &FileId) -> BackendResult<Box<dyn Read>> {
self.inner.read_file(path, id).await
}
Expand Down
9 changes: 9 additions & 0 deletions lib/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,15 @@ pub trait Backend: Send + Sync + Debug {

fn empty_tree_id(&self) -> &TreeId;

/// An estimate of how many concurrent requests this backend handles well. A
/// local backend like the Git backend (at until it supports partial clones)
/// may want to set this to 1. A cloud-backed backend may want to set it to
/// 100 or so.
///
/// It is not guaranteed that at most this number of concurrent requests are
/// sent.
fn concurrency(&self) -> usize;
martinvonz marked this conversation as resolved.
Show resolved Hide resolved

async fn read_file(&self, path: &RepoPath, id: &FileId) -> BackendResult<Box<dyn Read>>;

fn write_file(&self, path: &RepoPath, contents: &mut dyn Read) -> BackendResult<FileId>;
Expand Down
4 changes: 4 additions & 0 deletions lib/src/git_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@ impl Backend for GitBackend {
&self.empty_tree_id
}

fn concurrency(&self) -> usize {
1
}

async fn read_file(&self, _path: &RepoPath, id: &FileId) -> BackendResult<Box<dyn Read>> {
self.read_file_sync(id)
}
Expand Down
4 changes: 4 additions & 0 deletions lib/src/local_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ impl Backend for LocalBackend {
&self.empty_tree_id
}

fn concurrency(&self) -> usize {
1
}

async fn read_file(&self, _path: &RepoPath, id: &FileId) -> BackendResult<Box<dyn Read>> {
let path = self.file_path(id);
let file = File::open(path).map_err(|err| map_not_found_err(err, id))?;
Expand Down
Loading