MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / materialize_parallel

Method materialize_parallel

atomic-repository/src/repository/materialize.rs:1241–1433  ·  view source on GitHub ↗

Materialize the working copy using parallel file processing. This is an optimized version of `materialize` that: 1. Buffers each file's content in memory (single allocation per file) 2. Processes files in parallel using rayon 3. Writes each file to disk in a single `fs::write` call 4. Computes content hashes in-memory (no read-back pass) File retrieval and write failures are returned to the call

(
        &self,
        working_copy: WorkingCopyId,
        only_paths: Option<std::collections::HashSet<String>>,
    )

Source from the content-addressed store, hash-verified

1239 /// File retrieval and write failures are returned to the caller; they are
1240 /// never converted into successful skips.
1241 pub fn materialize_parallel(
1242 &self,
1243 working_copy: WorkingCopyId,
1244 only_paths: Option<std::collections::HashSet<String>>,
1245 ) -> Result<MaterializeResult, RepositoryError> {
1246 self.validate_working_copy(working_copy)?;
1247 let operation_lock = self.try_lock_operation(working_copy)?;
1248 if let OperationHeadState::Diverged(heads) =
1249 self.consolidate_operation_heads_locked(&operation_lock)?
1250 {
1251 return Err(RepositoryError::OperationHeadsDiverged {
1252 scope: OperationScope::WorkingCopy(working_copy).to_string(),
1253 heads: heads.iter().map(ToString::to_string).collect(),
1254 });
1255 }
1256 let view_name = self.desired_view_name(working_copy)?;
1257 let full_materialization = only_paths.is_none();
1258 let (visibility, view_id, view_state) = {
1259 let txn = self
1260 .pristine
1261 .read_txn()
1262 .map_err(|e| RepositoryError::Database(e.to_string()))?;
1263 let view = txn
1264 .get_view(&view_name)
1265 .map_err(|e| RepositoryError::Database(e.to_string()))?
1266 .ok_or_else(|| RepositoryError::ViewNotFound {
1267 name: view_name.clone(),
1268 })?;
1269 (graph_visibility_closure(&txn, &view)?, view.id, view.state)
1270 };
1271 // Only immutable decoded bytes are reused across plan/execution. Each
1272 // new context still checks its own dependency/span indexes, and cache
1273 // hits re-read and fingerprint the actual change files.
1274 let verified_changes = MaterializationVerifiedChanges::new(
1275 &self.change_store,
1276 visibility.len().min(MAX_MATERIALIZATION_VERIFIED_CHANGES),
1277 );
1278 let plan = self.plan_materialization_with_visibility(
1279 working_copy,
1280 only_paths.clone(),
1281 visibility.clone(),
1282 view_id,
1283 Some(&verified_changes),
1284 )?;
1285 let mut effects = Vec::new();
1286 for entry in plan {
1287 let target = EffectTarget::FilesystemPath {
1288 path: entry.path.clone(),
1289 };
1290 let observed = self.observe_filesystem_effect(working_copy, &target)?;
1291 let mut expected_new = entry.expected_new;
1292 match (&observed, &mut expected_new) {
1293 (EffectValue::Absent, EffectValue::File(new)) if new.kind == FileKind::Symlink => {
1294 // Linux `symlink(2)` ignores umask and yields the
1295 // platform's full-permission creation mode; probing a
1296 // directory's umask mask would mispredict the lease.
1297 new.mode = u32::from(atomic_core::output::platform_symlink_mode());
1298 }

Callers 5

materializeMethod · 0.45
materialize_pathsMethod · 0.45
materialize_prefixMethod · 0.45

Calls 15

WorkingCopyInterface · 0.85
graph_visibility_closureFunction · 0.85
platform_symlink_modeFunction · 0.85
working_copy_state_refFunction · 0.85
validate_working_copyMethod · 0.80
try_lock_operationMethod · 0.80
desired_view_nameMethod · 0.80
is_noneMethod · 0.80
read_txnMethod · 0.80

Tested by

no test coverage detected