Skip to content

perf: static-arity dims in variable() + fix StaticString null padding#45

Merged
Beforerr merged 1 commit into
mainfrom
push-qxmwqryvlnwp
Jun 11, 2026
Merged

perf: static-arity dims in variable() + fix StaticString null padding#45
Beforerr merged 1 commit into
mainfrom
push-qxmwqryvlnwp

Conversation

@Beforerr

Copy link
Copy Markdown
Member

variable(): @nif branch over num_record_dims (CDF caps at 10) -> dims tuple arity known at compile time.
staticstring: isvalid calls Base._thisind_str direct, delete local copy + Base.thisind override (invalidated 476 Base MethodInstances at load).
staticstring: ncodeunits trims trailing-null padding so length/collect/String/isvalid agree with iterate; collect on padded strings returned undef garbage before.

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1)

Time benchmarks
main f82a335... main / f82a335...
elx/full_load 0.122 ± 0.0079 ms 0.121 ± 0.0079 ms 1.01 ± 0.093
elx/sum_array 3.37 ± 0.7 μs 3.18 ± 0.64 μs 1.06 ± 0.31
elx/sum_lazy 3.38 ± 0.88 μs 3.09 ± 1.3 μs 1.09 ± 0.54
elx/sum_var_access 3.98 ± 0.68 μs 3.68 ± 0.99 μs 1.08 ± 0.35
elx/var_access 0.3 ± 0.081 μs 0.31 ± 0.11 μs 0.968 ± 0.43
mms/full_load 27.2 ± 3.1 μs 27.1 ± 3.1 μs 1.01 ± 0.16
mms/sum_array 0.0985 ± 0.003 s 0.0985 ± 0.0037 s 1 ± 0.048
mms/sum_slice 3.68 ± 0.11 ms 3.67 ± 0.44 ms 1 ± 0.12
mms/sum_var_access 3.66 ± 0.072 ms 3.68 ± 0.44 ms 0.994 ± 0.12
mms/var_access 0.13 ± 0.041 μs 0.11 ± 0.03 μs 1.18 ± 0.49
time_to_load 0.137 ± 0.0013 s 0.141 ± 0.0023 s 0.976 ± 0.018
Memory benchmarks
main f82a335... main / f82a335...
elx/full_load 3.73 k allocs: 0.167 MB 3.73 k allocs: 0.167 MB 1
elx/sum_array 5 allocs: 27.7 kB 5 allocs: 27.7 kB 1
elx/sum_lazy 5 allocs: 27.7 kB 5 allocs: 27.7 kB 1
elx/sum_var_access 8 allocs: 28.1 kB 8 allocs: 28.1 kB 1
elx/var_access 2 allocs: 0.328 kB 2 allocs: 0.328 kB 1
mms/full_load 0.243 k allocs: 14.8 kB 0.243 k allocs: 14.8 kB 1
mms/sum_array 0.524 k allocs: 31.6 MB 0.524 k allocs: 31.6 MB 1
mms/sum_slice 0.045 k allocs: 1.29 MB 0.045 k allocs: 1.29 MB 1
mms/sum_var_access 0.045 k allocs: 1.29 MB 0.045 k allocs: 1.29 MB 1
mms/var_access 2 allocs: 0.328 kB 2 allocs: 0.328 kB 1
time_to_load 0.145 k allocs: 11 kB 0.145 k allocs: 11 kB 1

@Beforerr Beforerr force-pushed the push-qxmwqryvlnwp branch from 055617c to d1a4842 Compare June 11, 2026 15:26
…le reads

variable() branches over the record-dim count and the data-type code so
CDFVariable construction is fully static: no _apply_iterate splat, no
generic-dispatch lookup, no argument boxing (elx var_access 861->195 ns,
6->4 allocs, 544->384 B).

CDFVariable drops the VDR/dataset type parameters (union fields); a typed
destination then pins the complete CDFVariable{T,N}, making read!(var, dest)
and read(var, Array{T,N}) resolve statically under juliac --trim even though
ds[name] is runtime-typed. Array{T,N}(var) constructors added for native use
(not trim-resolvable: Base convert-constructors compete).

Also fixes StaticString null padding.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Beforerr Beforerr force-pushed the push-qxmwqryvlnwp branch from d1a4842 to f82a335 Compare June 11, 2026 15:33
@Beforerr Beforerr merged commit 1e34009 into main Jun 11, 2026
@Beforerr Beforerr deleted the push-qxmwqryvlnwp branch June 11, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant