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