Skip to content

Commit 91e4cf1

Browse files
committed
remove this
1 parent edb449c commit 91e4cf1

File tree

4 files changed

+66
-19
lines changed

4 files changed

+66
-19
lines changed

gix-odb/src/store_impls/dynamic/init.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ impl Default for Options {
3232
}
3333
}
3434

35-
/// Configures the amount of slots in the index slotmap, which is fixed throughout the existence of the store.
35+
/// Configures the number of slots in the index slotmap, which is fixed throughout the existence of the store.
3636
#[derive(Copy, Clone, Debug)]
3737
pub enum Slots {
38-
/// The amount of slots to use, that is the total amount of indices we can hold at a time.
38+
/// The number of slots to use, that is the total number of indices we can hold at a time.
3939
/// Using this has the advantage of avoiding an initial directory listing of the repository, and is recommended
4040
/// on the server side where the repository setup is controlled.
4141
///
4242
/// Note that this won't affect their packs, as each index can have one or more packs associated with it.
4343
Given(u16),
44-
/// Compute the amount of slots needed, as probably best used on the client side where a variety of repositories is encountered.
44+
/// Compute the number of slots needed, as probably best used on the client side where a variety of repositories is encountered.
4545
AsNeededByDiskState {
4646
/// 1.0 means no safety, 1.1 means 10% more slots than needed
4747
multiplier: f32,
48-
/// The minimum amount of slots to assume
48+
/// The minimum number of slots to assume
4949
minimum: usize,
5050
},
5151
}

gix-odb/src/store_impls/dynamic/load_index.rs

+7
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ impl super::Store {
257257

258258
// Figure out this number based on what we see while handling the existing indices
259259
let mut num_loaded_indices = 0;
260+
dbg!(indices_by_modification_time.len());
260261
for (index_info, mtime) in indices_by_modification_time.into_iter().map(|(a, b, _)| (a, b)) {
261262
match idx_by_index_path.remove(index_info.path()) {
262263
Some(slot_idx) => {
@@ -295,6 +296,12 @@ impl super::Store {
295296
.map_or(0, |idx| (idx + 1) % self.files.len());
296297
let mut num_indices_checked = 0;
297298
let mut needs_generation_change = false;
299+
dbg!(
300+
index_paths_to_add.len(),
301+
next_possibly_free_index,
302+
self.files.len(),
303+
&index.slot_indices
304+
);
298305
let mut slot_indices_to_remove: Vec<_> = idx_by_index_path.into_values().collect();
299306
while let Some((mut index_info, mtime, move_from_slot_idx)) = index_paths_to_add.pop_front() {
300307
'increment_slot_index: loop {

gix-odb/src/store_impls/dynamic/types.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,11 @@ impl PackId {
8484
/// An index that changes only if the packs directory changes and its contents is re-read.
8585
#[derive(Default)]
8686
pub struct SlotMapIndex {
87-
/// The index into the slot map at which we expect an index or pack file. Neither of these might be loaded yet.
87+
/// The index into the slot map at which we expect an index or pack file. Neither of these might be already loaded.
8888
pub(crate) slot_indices: Vec<usize>,
89-
/// A list of loose object databases as resolved by their alternates file in the `object_directory`. The first entry is this objects
90-
/// directory loose file database. All other entries are the loose stores of alternates.
89+
/// A list of loose object databases as resolved by their alternates file in the `object_directory`.
90+
/// The first entry is this repository's directory for the loose file database.
91+
/// All other entries are the loose stores of alternates.
9192
/// It's in an Arc to be shared to Handles, but not to be shared across SlotMapIndices.
9293
pub(crate) loose_dbs: Arc<Vec<crate::loose::Store>>,
9394

gix/tests/gix/remote/fetch.rs

+51-12
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,39 @@ mod blocking_and_async_io {
102102
)?;
103103
Ok(())
104104
}
105+
fn check_fetch_output(
106+
repo: &gix::Repository,
107+
out: gix::remote::fetch::Outcome,
108+
expected_count: usize,
109+
) -> gix_testtools::Result {
110+
for local_tracking_branch_name in out.ref_map.mappings.into_iter().filter_map(|m| m.local) {
111+
let r = repo.find_reference(&local_tracking_branch_name)?;
112+
r.id()
113+
.object()
114+
.expect("object should be present after fetching, triggering pack refreshes works");
115+
repo.head_ref()?.unwrap().set_target_id(r.id(), "post fetch")?;
116+
}
117+
check_odb_accessability(repo, expected_count)?;
118+
Ok(())
119+
}
120+
fn check_odb_accessability(repo: &gix::Repository, expected_count: usize) -> gix_testtools::Result {
121+
let mut count_unique = 0;
122+
// TODO: somehow there is a lot of duplication when receiving objects.
123+
let mut seen = gix_hashtable::HashSet::default();
124+
for id in repo.objects.iter()? {
125+
let id = id?;
126+
if !seen.insert(id) {
127+
continue;
128+
}
129+
let _obj = repo.find_object(id)?;
130+
count_unique += 1;
131+
}
132+
assert_eq!(
133+
count_unique, expected_count,
134+
"Each round we receive exactly one commit, effectively"
135+
);
136+
Ok(())
137+
}
105138
for max_packs in 1..=3 {
106139
let remote_dir = tempfile::tempdir()?;
107140
let mut remote_repo = gix::init_bare(remote_dir.path())?;
@@ -128,25 +161,31 @@ mod blocking_and_async_io {
128161
Fetch,
129162
)
130163
.expect("remote is configured after clone")?;
131-
for _round_to_create_pack in 1..12 {
164+
let Slots::AsNeededByDiskState {
165+
multiplier: _,
166+
minimum: minimum_slots,
167+
} = Slots::default()
168+
else {
169+
unreachable!("The default for slotmappings is dynamic");
170+
};
171+
let one_more_than_minimum = minimum_slots + 1;
172+
for round_to_create_pack in 1..one_more_than_minimum {
173+
let expected_object_count = round_to_create_pack + 1 + 1 /* first commit + tree */;
132174
create_empty_commit(&remote_repo)?;
133175
match remote
134176
.connect(Fetch)?
135177
.prepare_fetch(gix::progress::Discard, Default::default())?
136178
.receive(gix::progress::Discard, &IS_INTERRUPTED)
137179
{
138-
Ok(out) => {
139-
for local_tracking_branch_name in out.ref_map.mappings.into_iter().filter_map(|m| m.local) {
140-
let r = local_repo.find_reference(&local_tracking_branch_name)?;
141-
r.id()
142-
.object()
143-
.expect("object should be present after fetching, triggering pack refreshes works");
144-
local_repo.head_ref()?.unwrap().set_target_id(r.id(), "post fetch")?;
145-
}
180+
Ok(out) => check_fetch_output(&local_repo, out, expected_object_count)?,
181+
Err(err) => {
182+
assert!(err
183+
.to_string()
184+
.starts_with("The slotmap turned out to be too small with "));
185+
// But opening a new repo will always be able to read all objects.
186+
let local_repo = gix::open_opts(local_repo.path(), gix::open::Options::isolated())?;
187+
check_odb_accessability(&local_repo, expected_object_count)?;
146188
}
147-
Err(err) => assert!(err
148-
.to_string()
149-
.starts_with("The slotmap turned out to be too small with ")),
150189
}
151190
}
152191
}

0 commit comments

Comments
 (0)