format: slice entry points for the facade's hot *_in calls (local listing back to main's speed)
CI / test-arm64 (pull_request) Successful in 1m25s
CI / test (pull_request) Successful in 19m0s

Since the M2 merge the facade handed in-memory files to the generic
`*_in` parsers as `&[u8]` (`with_bytes!`), which instantiates them in
the facade crate, where the format crate's private helpers do not
inline without LTO: listing a 400-group v1 file through `File::open`
was 7-10% slower than main. `ObjectHeader::parse_in`,
`group_v2::{resolve_child_in, resolve_group_children_in,
resolve_path_any_in}` and `attribute::{extract_attributes_tolerant_in,
find_attribute_in}` now pass a storage with `as_contiguous()` to their
non-generic slice entry point, compiled once in the format crate; other
storages reach the same generic core as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
osobh
2026-09-26 22:28:22 -05:00
co-authored by Claude Opus 5.5
parent 4313917b4d
commit ef428d756c
5 changed files with 151 additions and 12 deletions
+49 -6
View File
@@ -368,15 +368,30 @@ pub fn resolve_child(
group_address: u64,
name: &str,
) -> Result<u64, FormatError> {
resolve_child_in(file_data, superblock, group_address, name)
resolve_child_core(file_data, superblock, group_address, name)
}
/// [`resolve_child`] over any [`Storage`].
/// [`resolve_child`] over any [`Storage`]. One with the whole file in memory
/// is read as the slice, by code compiled in this crate (see
/// [`crate::storage`], "Slice entry points").
#[inline]
pub fn resolve_child_in<S: Storage + ?Sized>(
file_data: &S,
superblock: &Superblock,
group_address: u64,
name: &str,
) -> Result<u64, FormatError> {
match file_data.as_contiguous() {
Some(all) => resolve_child(all, superblock, group_address, name),
None => resolve_child_core(file_data, superblock, group_address, name),
}
}
fn resolve_child_core<S: Storage + ?Sized>(
file_data: &S,
superblock: &Superblock,
group_address: u64,
name: &str,
) -> Result<u64, FormatError> {
let os = superblock.offset_size;
let ls = superblock.length_size;
@@ -453,14 +468,28 @@ pub fn resolve_path_any(
superblock: &Superblock,
path: &str,
) -> Result<u64, FormatError> {
resolve_path_any_in(file_data, superblock, path)
resolve_path_any_core(file_data, superblock, path)
}
/// [`resolve_path_any`] over any [`Storage`].
/// [`resolve_path_any`] over any [`Storage`]. One with the whole file in memory
/// is read as the slice, by code compiled in this crate (see
/// [`crate::storage`], "Slice entry points").
#[inline]
pub fn resolve_path_any_in<S: Storage + ?Sized>(
file_data: &S,
superblock: &Superblock,
path: &str,
) -> Result<u64, FormatError> {
match file_data.as_contiguous() {
Some(all) => resolve_path_any(all, superblock, path),
None => resolve_path_any_core(file_data, superblock, path),
}
}
fn resolve_path_any_core<S: Storage + ?Sized>(
file_data: &S,
superblock: &Superblock,
path: &str,
) -> Result<u64, FormatError> {
resolve_path_following_links(
file_data,
@@ -513,14 +542,28 @@ pub fn resolve_group_children(
superblock: &Superblock,
group_address: u64,
) -> Result<Vec<GroupEntry>, FormatError> {
resolve_group_children_in(file_data, superblock, group_address)
resolve_group_children_core(file_data, superblock, group_address)
}
/// [`resolve_group_children`] over any [`Storage`].
/// [`resolve_group_children`] over any [`Storage`]. One with the whole file in memory
/// is read as the slice, by code compiled in this crate (see
/// [`crate::storage`], "Slice entry points").
#[inline]
pub fn resolve_group_children_in<S: Storage + ?Sized>(
file_data: &S,
superblock: &Superblock,
group_address: u64,
) -> Result<Vec<GroupEntry>, FormatError> {
match file_data.as_contiguous() {
Some(all) => resolve_group_children(all, superblock, group_address),
None => resolve_group_children_core(file_data, superblock, group_address),
}
}
fn resolve_group_children_core<S: Storage + ?Sized>(
file_data: &S,
superblock: &Superblock,
group_address: u64,
) -> Result<Vec<GroupEntry>, FormatError> {
let os = superblock.offset_size;
let ls = superblock.length_size;