format: slice entry points for the facade's hot *_in calls (local listing back to main's speed)
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:
@@ -149,6 +149,32 @@
|
||||
inside the file is an error.
|
||||
- **No behaviour change for in-memory and mapped files:** with
|
||||
`as_contiguous()` every path slices the file as before (checked below).
|
||||
- **Speed on local files** (provisional: tank was shared with other jobs,
|
||||
load 4–16 during the runs; Criterion `local_metadata_bench`, `main`
|
||||
`8f59b2e` and this branch as separate binaries, 8 alternating rounds,
|
||||
best round of each). Listing the 400-group version-1 file through the
|
||||
facade (`File::open`, mmap) had become 7–10% slower than `main` (8.95–9.04
|
||||
vs 8.14–8.36 ms), from the M2 merge on (bisected over the merges: `main`
|
||||
8.17–8.27, `2893b6c` 8.69–8.76, `93e2d5f`/`7447dce`/`4313917` the same).
|
||||
The parsers were unchanged: the facade now called the generic `*_in`
|
||||
entry points with the slice (`with_bytes!`), which instantiates each
|
||||
parser in the facade crate, where the format crate's private helpers do
|
||||
not inline (no LTO); `main` called the `&[u8]` wrappers, compiled in the
|
||||
format crate. Routing just `resolve_child`/`resolve_group_children` to
|
||||
the wrappers took the listing from 8.66–8.70 to 8.33–8.46 ms. Fixed in
|
||||
the format crate: `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}` hand a
|
||||
storage with `as_contiguous()` to their non-generic slice entry point,
|
||||
compiled once in the format crate; everything else goes to the same
|
||||
generic core as before, so `File::open_storage` is unchanged. Best
|
||||
rounds, `main` / before / after: facade listing 8.49 / 9.07 / 8.68 ms
|
||||
(+2.2% on `main`, was +6.9%); `ObjectHeader::parse` ×401 24.91 / 25.90 /
|
||||
25.51 µs; symbol-table nodes 1.99 / 1.94 / 1.94 µs; group B-tree walk
|
||||
360.6 / 365.0 / 361.1 ns. The B-tree walk's `btree_v1.rs` is identical to
|
||||
`main` and it calls only format-crate code; its earlier +5–10% (323–355
|
||||
vs 353–363 ns) was run-to-run layout noise (at `2893b6c` it measured
|
||||
357–374 ns against `main`'s 355–371 in the same rounds).
|
||||
- Tests (2026-09-26, tank):
|
||||
- `clawhdf5-format/tests/storage_equivalence.rs` now also reads every
|
||||
dataset — whole, fill-aware, through a chunk cache (twice) and the
|
||||
|
||||
Reference in New Issue
Block a user