Skip to content

fix(tdigest): validate deserialized state invariants - #262

Merged
tisonkun merged 2 commits into
mainfrom
codex/tdigest-deserialize-validation
Sep 2, 2026
Merged

fix(tdigest): validate deserialized state invariants#262
tisonkun merged 2 commits into
mainfrom
codex/tdigest-deserialize-validation

Conversation

@tisonkun

@tisonkun tisonkun commented Sep 2, 2026

Copy link
Copy Markdown
Member

Summary

  • reject unknown or mutually exclusive T-Digest serialization flags
  • validate finite, ordered extrema and require non-empty images to store at least one value
  • validate centroid ordering and range membership, plus buffered-value range membership
  • apply equivalent structural checks to the compatibility formats

Performance

The validation loops deliberately accumulate the floating-point predicates and branch once after each payload. This keeps valid-state deserialization on a straight-line fast path.

Paired Divan runs against origin/main on the same machine:

Benchmark origin/main This PR Change
deserialize_partial_groups (large) 102.2 µs 72.22 µs -29.3%
deserialize_partial_groups (small) 19.2 µs 16.06 µs -16.4%

Allocation counts and bytes were unchanged. The speedup comes from fusing the former per-value NaN and finite checks into the structural validation pass; the main purpose of this PR remains rejecting malformed states rather than promising a particular performance gain.

Validation

  • cargo x prepare-testdata
  • cargo x check
  • cargo x lint
  • cargo x test

@tisonkun
tisonkun enabled auto-merge (squash) September 2, 2026 04:09
@tisonkun
tisonkun merged commit 285ae24 into main Sep 2, 2026
10 checks passed
@tisonkun
tisonkun deleted the codex/tdigest-deserialize-validation branch September 2, 2026 04:11
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