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

Function rolling_sample

atomic-cli/src/commands/git/stream.rs:1093–1280  ·  view source on GitHub ↗

Test-only prototype: preflight one commit at a time, then keep a count- and input-blob-budgeted window feeding the existing private publisher. It deliberately does not replace the CLI's checkout/adoption preflight.

(
        importer: &ParallelImporter,
        repo: &mut Repository,
        tip: Oid,
        window_size: usize,
        batch_size: usize,
        window_blob_limit: usize,
    )

Source from the content-addressed store, hash-verified

1091 /// count- and input-blob-budgeted window feeding the existing private publisher.
1092 /// It deliberately does not replace the CLI's checkout/adoption preflight.
1093 fn rolling_sample(
1094 importer: &ParallelImporter,
1095 repo: &mut Repository,
1096 tip: Oid,
1097 window_size: usize,
1098 batch_size: usize,
1099 window_blob_limit: usize,
1100 ) -> CliResult<(GitStreamOutcome, usize, usize, usize, usize, f64)> {
1101 assert!(window_size > 0 && batch_size > 0 && batch_size <= window_size);
1102 let _recorder_guard = RecorderGuard::new();
1103 let mut dashboard = rolling_dashboard::Dashboard::start(
1104 window_size,
1105 window_blob_limit,
1106 std::env::var_os("ATOMIC_ROLLING_DASHBOARD").is_some(),
1107 );
1108 rolling_memory_sample("before_preflight", 0, 0, 0, 0)?;
1109 let preflight_start = Instant::now();
1110 let (git, policy, ordered) = importer.graph_stream_inputs(tip)?;
1111 dashboard.update(|state| state.total = ordered.len());
1112 let positions: HashMap<_, _> = ordered
1113 .iter()
1114 .copied()
1115 .enumerate()
1116 .map(|(index, oid)| (oid, index))
1117 .collect();
1118 let limits = GitStreamLimits::new(batch_size, 32 * 1024 * 1024).map_err(CliError::from)?;
1119
1120 // Retain only the immediately preceding prospective project. For a
1121 // different parent, apply_commit reloads its tree from the ODB.
1122 let mut prospective = ProspectiveProjectTree::new(policy.clone(), None)?;
1123 for (index, oid) in ordered.iter().copied().enumerate() {
1124 let commit = git.find_commit(oid).map_err(|e| git_error(e.to_string()))?;
1125 input_budget(&git, &commit, limits.bytes())?;
1126 if input_blob_bytes(&git, &commit)? > window_blob_limit {
1127 return Err(git_error(format!(
1128 "commit {oid} exceeds rolling window input-blob budget"
1129 )));
1130 }
1131 let parsed = parse_commit(&git, oid, index, &positions)?;
1132 prospective.apply_commit(&parsed, Some(&git))?;
1133 prospective
1134 .manifests
1135 .retain(|tree, _| *tree == parsed.tree_oid);
1136 dashboard.update(|state| state.checked = index + 1);
1137 }
1138 drop(prospective);
1139 let preflight_seconds = preflight_start.elapsed().as_secs_f64();
1140 rolling_memory_sample("after_preflight", 0, 0, 0, 0)?;
1141
1142 let mut session = GitGraphImportSession::begin(repo, limits).map_err(CliError::from)?;
1143 let mut compiler = Compiler::default();
1144 let mut pending = VecDeque::new();
1145 let mut next = 0usize;
1146 let mut processed = 0usize;
1147 let mut advances = 0usize;
1148 let mut peak = 0usize;
1149 let mut pending_bytes = 0usize;
1150 let mut peak_bytes = 0usize;

Calls 15

rolling_memory_sampleFunction · 0.85
input_budgetFunction · 0.85
input_blob_bytesFunction · 0.85
parse_commitFunction · 0.85
parse_commit_with_scopeFunction · 0.85
import_expected_tree_oidFunction · 0.85
graph_stream_inputsMethod · 0.80
apply_commitMethod · 0.80
enabledMethod · 0.80
build_git_metadataMethod · 0.80