Skip to content

Commit ec37db4

Browse files
committed
feat: Provide information about whether or not EOIE and IEOT extensions were available.
These are only relevant when reading, and have to be regenerated after writing. During reading, they can speed up performance by allowing multi-threading.
1 parent cbda06d commit ec37db4

File tree

7 files changed

+30
-2
lines changed

7 files changed

+30
-2
lines changed

gix-index/src/access/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,14 @@ impl State {
557557
pub fn fs_monitor(&self) -> Option<&extension::FsMonitor> {
558558
self.fs_monitor.as_ref()
559559
}
560+
/// Return `true` if the end-of-index extension was present when decoding this index.
561+
pub fn had_end_of_index_marker(&self) -> bool {
562+
self.end_of_index_at_decode_time
563+
}
564+
/// Return `true` if the offset-table extension was present when decoding this index.
565+
pub fn had_offset_table(&self) -> bool {
566+
self.offset_table_at_decode_time
567+
}
560568
}
561569

562570
#[cfg(test)]

gix-index/src/decode/entries.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ fn load_one<'a>(
134134
(path, skip_padding(data, first_byte_of_entry))
135135
};
136136

137+
// TODO(perf): for some reason, this causes tremendous `memmove` time even though the backing
138+
// has enough capacity most of the time.
137139
path_backing.extend_from_slice(path);
138140
data
139141
};

gix-index/src/decode/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ impl State {
236236
untracked,
237237
fs_monitor,
238238
is_sparse: is_sparse_from_ext, // a marker is needed in case there are no directories
239+
end_of_index,
240+
offset_table,
239241
} = ext;
240242
is_sparse |= is_sparse_from_ext;
241243

@@ -248,6 +250,8 @@ impl State {
248250
path_backing,
249251
is_sparse,
250252

253+
end_of_index_at_decode_time: end_of_index,
254+
offset_table_at_decode_time: offset_table,
251255
tree,
252256
link,
253257
resolve_undo,

gix-index/src/extension/decode.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ pub(crate) fn all(
5050
extension::fs_monitor::SIGNATURE => {
5151
ext.fs_monitor = extension::fs_monitor::decode(ext_data);
5252
}
53-
extension::end_of_index_entry::SIGNATURE => {} // skip already done
54-
extension::index_entry_offset_table::SIGNATURE => {} // not relevant/obtained already
53+
extension::end_of_index_entry::SIGNATURE => {
54+
ext.end_of_index = true;
55+
} // skip already done
56+
extension::index_entry_offset_table::SIGNATURE => {
57+
ext.offset_table = true;
58+
} // not relevant/obtained already
5559
mandatory if mandatory[0].is_ascii_lowercase() => match mandatory {
5660
extension::link::SIGNATURE => ext.link = extension::link::decode(ext_data, object_hash)?.into(),
5761
extension::sparse::SIGNATURE => {
@@ -77,4 +81,6 @@ pub(crate) struct Outcome {
7781
pub untracked: Option<extension::UntrackedCache>,
7882
pub fs_monitor: Option<extension::FsMonitor>,
7983
pub is_sparse: bool,
84+
pub offset_table: bool,
85+
pub end_of_index: bool,
8086
}

gix-index/src/init.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ mod from_tree {
2626
resolve_undo: None,
2727
untracked: None,
2828
fs_monitor: None,
29+
offset_table_at_decode_time: false,
30+
end_of_index_at_decode_time: false,
2931
}
3032
}
3133
/// Create an index [`State`] by traversing `tree` recursively, accessing sub-trees
@@ -63,6 +65,8 @@ mod from_tree {
6365
resolve_undo: None,
6466
untracked: None,
6567
fs_monitor: None,
68+
offset_table_at_decode_time: false,
69+
end_of_index_at_decode_time: false,
6670
})
6771
}
6872
}

gix-index/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ pub struct State {
128128
is_sparse: bool,
129129

130130
// Extensions
131+
end_of_index_at_decode_time: bool,
132+
offset_table_at_decode_time: bool,
131133
tree: Option<extension::Tree>,
132134
link: Option<extension::Link>,
133135
resolve_undo: Option<extension::resolve_undo::Paths>,

gix-index/tests/index/file/read.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ fn file_with_conflicts() {
227227
fn v4_with_delta_paths_and_ieot_ext() {
228228
let file = file("v4_more_files_IEOT");
229229
assert_eq!(file.version(), Version::V4);
230+
assert!(file.had_end_of_index_marker());
231+
assert!(file.had_offset_table());
230232

231233
assert_eq!(file.entries().len(), 10);
232234
for (idx, path) in [

0 commit comments

Comments
 (0)