refactor(tvix/store/bin): instantiating TvixStoreIO once
Instead of instantiating it once in every loop iteration, put it in an Arc, and clone that before passing it to the spawned task. Change-Id: I5d9c838f27048726166fa50206d1edd5ed6849b5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8632 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
22776280b5
commit
a4d0a80466
1 changed files with 11 additions and 9 deletions
|
@ -2,6 +2,7 @@ use clap::Subcommand;
|
|||
use data_encoding::BASE64;
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use tracing_subscriber::prelude::*;
|
||||
use tvix_store::blobservice::SledBlobService;
|
||||
use tvix_store::directoryservice::SledDirectoryService;
|
||||
|
@ -129,18 +130,19 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
directory_service.clone(),
|
||||
);
|
||||
|
||||
let io = Arc::new(TvixStoreIO::new(
|
||||
blob_service,
|
||||
directory_service,
|
||||
path_info_service,
|
||||
nar_calculation_service,
|
||||
));
|
||||
|
||||
for path in paths {
|
||||
let path_move = path.clone();
|
||||
|
||||
let mut io = TvixStoreIO::new(
|
||||
blob_service.clone(),
|
||||
directory_service.clone(),
|
||||
path_info_service.clone(),
|
||||
nar_calculation_service.clone(),
|
||||
);
|
||||
|
||||
let io_move = io.clone();
|
||||
let path_info = tokio::task::spawn_blocking(move || {
|
||||
io.import_path_with_pathinfo(&path_move)
|
||||
io_move
|
||||
.import_path_with_pathinfo(&path_move)
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))
|
||||
})
|
||||
.await??;
|
||||
|
|
Loading…
Reference in a new issue