Skip to content

feat: separate dictionary safety and correctness validation - #24

Merged
gargiulofrancesco merged 2 commits into
developfrom
feat/safety-correctness-validation
Jul 22, 2026
Merged

feat: separate dictionary safety and correctness validation#24
gargiulofrancesco merged 2 commits into
developfrom
feat/safety-correctness-validation

Conversation

@gargiulofrancesco

Copy link
Copy Markdown
Member

Summary

  • Split dictionary validation into safety and correctness paths.
  • Keep safety validation limited to the invariants required for bounded decoding and tokenization.
  • Move sortedness, uniqueness, and alphabet completeness checks to correctness validation.
  • Add optimized direct safety validation for WideDictionary.
  • Add tests covering structurally safe but semantically malformed dictionaries.

Motivation

Consumers such as Vortex need to guarantee memory safety during decoding without paying the cost of full semantic validation. Malformed dictionaries may produce incorrect results, but must not cause out-of-bounds reads, writes, or non-terminating tokenization.

Testing

  • cargo build --all-features --all-targets
  • cargo fmt --all --check
  • cargo clippy --all-features --all-targets
  • cargo doc --no-deps --all-features --document-private-items
  • cargo test --workspace --all-features

All checks passed.

Signed-off-by: Francesco Gargiulo <gargiulo.fr@gmail.com>
Signed-off-by: Francesco Gargiulo <gargiulo.fr@gmail.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codspeed-hq

codspeed-hq Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will regress 4 benchmarks

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 11 improved benchmarks
❌ 4 regressed benchmarks
✅ 17 untouched benchmarks
⏩ 2 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime decompress_all[("l_comment", 16)] 14.3 ms 19.4 ms -26.3%
WallTime decompress_all[("o_comment", 12)] 11.1 ms 14.8 ms -25.17%
WallTime decompress_all[("o_comment", 16)] 13 ms 16.7 ms -22.08%
WallTime decompress_all[("l_comment", 12)] 12 ms 15.4 ms -21.77%
WallTime decompress_all[16] 514.9 µs 395.3 µs +30.26%
WallTime decompress_all[12] 489.4 µs 379.6 µs +28.91%
WallTime decompress_all[("p_name", 12)] 769.1 µs 630.6 µs +21.96%
WallTime train_and_compress[12] 39.2 ms 32.8 ms +19.57%
WallTime decompress_all[("p_name", 16)] 701.8 µs 588.6 µs +19.24%
WallTime train_and_compress[16] 42.1 ms 35.6 ms +18.41%
WallTime train_and_compress[("o_comment", 16)] 507.8 ms 441.6 ms +14.98%
WallTime train_and_compress[("p_name", 16)] 42.2 ms 37 ms +14.02%
WallTime train_and_compress[("l_comment", 12)] 481.3 ms 426.4 ms +12.88%
WallTime train_and_compress[("o_comment", 12)] 401.5 ms 357.4 ms +12.33%
WallTime train_and_compress[("l_comment", 16)] 591.5 ms 534.3 ms +10.72%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/safety-correctness-validation (d3607a0) with develop (3f71342)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@gargiulofrancesco
gargiulofrancesco merged commit 5534b59 into develop Jul 22, 2026
9 of 12 checks passed
@gargiulofrancesco
gargiulofrancesco deleted the feat/safety-correctness-validation branch July 22, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants