ci: wire up CI, fix no_std build, fix stale package names in scripts
CI / test (push) Failing after 15s

- Add .gitea/workflows/ci.yml running scripts/ci-test.sh (fmt, clippy,
  test, no_std check) on push/PR to main.
- Fix stale rustyhdf5-py/rustyhdf5-format package names in
  ci-test.sh/check-nostd.sh, which had been silently no-op'ing those
  checks (cargo warns but doesn't fail on an unknown --exclude/-p
  target).
- With those checks actually running, fix the real issues they surface:
  - clippy: useless_conversion in chunked_write.rs, byte_char_slices in
    global_heap.rs/object_header.rs.
  - cargo fmt: apply formatting across the workspace (whitespace only).
  - no_std (thumbv7em-none-eabihf) build errors in clawhdf5-format:
    core::sync::atomic::AtomicU64 doesn't exist on that target (no
    native 64-bit atomics) — switch profiling.rs's counters to
    portable-atomic, which falls back to a CAS-based emulation there
    and is a no-op wrapper elsewhere. Add missing alloc imports for
    Box (filters.rs), Vec (filters_szip.rs), and format! (dict_encoding.rs)
    on no_std paths. Replace f64::powi (std/libm-only) with a small
    local exponentiation-by-squaring helper in the scale-offset filter.
This commit is contained in:
Omar Sobh
2026-08-05 10:50:13 -07:00
parent b70d594c4f
commit 55959b4920
34 changed files with 590 additions and 365 deletions
+13 -17
View File
@@ -41,11 +41,7 @@ fn bench_metadata_attrs_write(c: &mut Criterion) {
let path = tmp.path().join("attrs_libhdf5.h5");
b.iter(|| {
let file = hdf5::File::create(&path).unwrap();
let ds = file
.new_dataset::<f64>()
.shape([3])
.create("data")
.unwrap();
let ds = file.new_dataset::<f64>().shape([3]).create("data").unwrap();
ds.write(&[1.0f64, 2.0, 3.0]).unwrap();
for i in 0..k {
ds.new_attr::<i64>()
@@ -258,11 +254,7 @@ fn bench_metadata_open_from_disk(c: &mut Criterion) {
let libhdf5_path = tmp.path().join("open_libhdf5.h5");
{
let file = hdf5::File::create(&libhdf5_path).unwrap();
let ds = file
.new_dataset::<f64>()
.shape([3])
.create("data")
.unwrap();
let ds = file.new_dataset::<f64>().shape([3]).create("data").unwrap();
ds.write(&[1.0f64, 2.0, 3.0]).unwrap();
ds.new_attr::<i64>()
.create("label")
@@ -307,13 +299,17 @@ fn bench_metadata_parse_in_memory(c: &mut Criterion) {
fb.finish().unwrap()
};
group.bench_with_input(BenchmarkId::new("clawhdf5", "in_memory"), &bytes, |b, raw| {
b.iter(|| {
let file = File::from_bytes(raw.clone()).unwrap();
let ds = file.dataset("data").unwrap();
ds.attrs().unwrap()
});
});
group.bench_with_input(
BenchmarkId::new("clawhdf5", "in_memory"),
&bytes,
|b, raw| {
b.iter(|| {
let file = File::from_bytes(raw.clone()).unwrap();
let ds = file.dataset("data").unwrap();
ds.attrs().unwrap()
});
},
);
group.finish();
}
+18 -18
View File
@@ -74,11 +74,7 @@ fn bench_read_sequential(c: &mut Criterion) {
let data: Vec<f32> = (0..nn).map(|i| i as f32 * 0.001).collect();
{
let lf = hdf5::File::create(&path).unwrap();
let lds = lf
.new_dataset::<f32>()
.shape([nn])
.create("data")
.unwrap();
let lds = lf.new_dataset::<f32>().shape([nn]).create("data").unwrap();
lds.write(data.as_slice()).unwrap();
}
b.iter(|| {
@@ -235,19 +231,23 @@ fn bench_read_zerocopy_mmap(c: &mut Criterion) {
group.throughput(Throughput::Bytes((n * size_of::<f64>()) as u64));
group.bench_with_input(BenchmarkId::new("clawhdf5_mmap_zerocopy", n), &path, |b, p| {
b.iter(|| {
let file = MmapFile::open(p).unwrap();
let ds = file.dataset("data").unwrap();
let slice = ds.read_f64_zerocopy().unwrap();
// Sum every element to force the mapped pages to actually be
// faulted in — returning just `.len()` would measure nothing
// but the mmap() syscall, repeating the exact "too-fast-to-
// be-real" mistake this benchmark exists to fix.
let sum: f64 = slice.map(|s| s.iter().sum()).unwrap_or(0.0);
criterion::black_box(sum)
});
});
group.bench_with_input(
BenchmarkId::new("clawhdf5_mmap_zerocopy", n),
&path,
|b, p| {
b.iter(|| {
let file = MmapFile::open(p).unwrap();
let ds = file.dataset("data").unwrap();
let slice = ds.read_f64_zerocopy().unwrap();
// Sum every element to force the mapped pages to actually be
// faulted in — returning just `.len()` would measure nothing
// but the mmap() syscall, repeating the exact "too-fast-to-
// be-real" mistake this benchmark exists to fix.
let sum: f64 = slice.map(|s| s.iter().sum()).unwrap_or(0.0);
criterion::black_box(sum)
});
},
);
group.bench_with_input(BenchmarkId::new("clawhdf5_copy", n), &path, |b, p| {
b.iter(|| {
+23 -28
View File
@@ -63,11 +63,8 @@ fn bench_write_2d_chunked(c: &mut Criterion) {
let mut group = c.benchmark_group("write_2d_chunked");
// (rows, cols, chunk_rows, chunk_cols)
let configs: &[(usize, usize, u64, u64)] = &[
(32, 32, 8, 32),
(128, 128, 32, 128),
(512, 512, 64, 512),
];
let configs: &[(usize, usize, u64, u64)] =
&[(32, 32, 8, 32), (128, 128, 32, 128), (512, 512, 64, 512)];
for &(rows, cols, cr, cc) in configs {
let n = rows * cols;
@@ -120,11 +117,8 @@ fn bench_write_2d_chunked(c: &mut Criterion) {
fn bench_write_2d_chunked_zstd(c: &mut Criterion) {
let mut group = c.benchmark_group("write_2d_chunked_zstd");
let configs: &[(usize, usize, u64, u64)] = &[
(32, 32, 8, 32),
(128, 128, 32, 128),
(512, 512, 64, 512),
];
let configs: &[(usize, usize, u64, u64)] =
&[(32, 32, 8, 32), (128, 128, 32, 128), (512, 512, 64, 512)];
for &(rows, cols, cr, cc) in configs {
let n = rows * cols;
@@ -132,19 +126,23 @@ fn bench_write_2d_chunked_zstd(c: &mut Criterion) {
let label = format!("{rows}x{cols}");
group.throughput(Throughput::Bytes((n * size_of::<f32>()) as u64));
group.bench_with_input(BenchmarkId::new("clawhdf5/zstd-3", &label), &data, |b, d| {
let tmp = TempDir::new().unwrap();
let path = tmp.path().join("write_2d_chunked_zstd.h5");
b.iter(|| {
let mut fb = FileBuilder::new();
fb.create_dataset("matrix")
.with_f32_data(d)
.with_shape(&[rows as u64, cols as u64])
.with_chunks(&[cr, cc])
.with_zstd(3);
fb.write(&path).unwrap();
});
});
group.bench_with_input(
BenchmarkId::new("clawhdf5/zstd-3", &label),
&data,
|b, d| {
let tmp = TempDir::new().unwrap();
let path = tmp.path().join("write_2d_chunked_zstd.h5");
b.iter(|| {
let mut fb = FileBuilder::new();
fb.create_dataset("matrix")
.with_f32_data(d)
.with_shape(&[rows as u64, cols as u64])
.with_chunks(&[cr, cc])
.with_zstd(3);
fb.write(&path).unwrap();
});
},
);
group.bench_with_input(
BenchmarkId::new("clawhdf5/deflate-6", &label),
@@ -178,11 +176,8 @@ fn bench_write_2d_chunked_zstd(c: &mut Criterion) {
fn bench_write_2d_chunked_pcodec(c: &mut Criterion) {
let mut group = c.benchmark_group("write_2d_chunked_pcodec");
let configs: &[(usize, usize, u64, u64)] = &[
(32, 32, 8, 32),
(128, 128, 32, 128),
(512, 512, 64, 512),
];
let configs: &[(usize, usize, u64, u64)] =
&[(32, 32, 8, 32), (128, 128, 32, 128), (512, 512, 64, 512)];
for &(rows, cols, cr, cc) in configs {
let n = rows * cols;