Skip to content

perf: compare variable and attribute names in place - #78

Merged
Beforerr merged 3 commits into
mainfrom
perf-name-lookup
Oct 6, 2026
Merged

Beforerr merged 3 commits into
mainfrom
perf-name-lookup

Conversation

@Beforerr

@Beforerr Beforerr commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Stacked on #77.

Name lookups (ds[name], haskey, var.attrib[name], attrib(ds, name)) scanned each record's name field for its terminator and compared a view element-wise; attribute lookup also parsed every ADR first. Now one memcmp in the buffer, checking the terminator right after the requested length. ADR keeps the name's position instead of reading it, so the name is read only when returned (adr_name). First-call time is unchanged: 175–177 ms for opening ac_h0_mfi and reading every variable's attributes, before and after.

Looking up every variable / every variable attribute, before → after:

file ds[k] all vars v.attrib[a] all
elb_l2_epdef 3.58 → 0.81 µs 56.2 → 51.4 µs
ac_h0_mfi 1.79 → 1.27 µs 36.4 → 31.4 µs
ac_h2_sis (v2) 15.83 → 6.96 µs 143.9 → 123.0 µs

Also: name fields are 64 bytes in CDF v2 (cdflib, CDFpp cdf_string_field_t<version_t, 256, 64>), not 256, so readname read a v2 name filling its field into the following bytes. It only shows on v2 r-variables with dimensions, where DimVarys (-1) follows the name; no fixture has one.

Full suite passes, including JET and trim.

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.50746% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/parsing.jl 91.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

NOVARY dimensions aren't physically stored, so counting them read past
each variable's data. r-variables already dropped them; z-variables now
share that path. Matches CDFpp and cdflib.
Lookups by name scanned each record's name field for its terminator and
compared a view element-wise; attribute lookup also parsed every ADR
first. Compare with one memcmp in the buffer instead, and read an ADR's
name only when it is returned.

Name fields are 64 bytes in CDF v2, not 256, so a v2 name filling its
field was read into the following bytes.
@Beforerr
Beforerr changed the base branch from fix-novary-z to main October 6, 2026 13:57
@Beforerr
Beforerr merged commit 8c11b75 into main Oct 6, 2026
5 of 9 checks passed
@Beforerr
Beforerr deleted the perf-name-lookup branch October 6, 2026 13:57
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