Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Littany of Safety Enhancements #122

Merged
merged 11 commits into from
Sep 11, 2024
Merged

Initial Littany of Safety Enhancements #122

merged 11 commits into from
Sep 11, 2024

Conversation

Alexhuszagh
Copy link
Owner

This removes a lot of unsafe code, documents the cases where removing it would have significant performance impacts but the safety invariants can be easily guaranteed, and likewise makes other enhancements to remove potentially unsafe behavior. This also redoes some architecture to make more code wrapped into safe variants, where rather than say if x.get(0) == b'0'. then do an unchecked index, instead it just has a peek and step in a single function, where applicable.. This also simplifies the code base a lot.

Part of many commits to address #100.

The safety guarantees that aren't validated immediately have been
removed (so only keeping the unsafe code in the hi bit extraction, which
is checked right in the call), and this leads to ~3% degradation in
performance in the worst cases, which is still 90% faster than core so
it's well worth it. The unsafe code in the multiplication algorithms is
the cause of the slowdown, but well worth it.
Seems to improve performance on some edge case floats invoking this path
by up to 30%.
Introduce a self-contained `Buffer` trait that allows simpler comparison
of values, and then remove more unsafety, especially in cases where the
compiler can trivially provide the unsafety is sound. Then, also fix a
minor bug with formatting where the mantissa radix negative sign check
was used and not the exponent one.
@Alexhuszagh Alexhuszagh added high priority High priority A-sec Issues with potential security implications. labels Sep 11, 2024
@Alexhuszagh Alexhuszagh added this to the 1.0 milestone Sep 11, 2024
@Alexhuszagh Alexhuszagh self-assigned this Sep 11, 2024
@Alexhuszagh Alexhuszagh merged commit 19bf353 into main Sep 11, 2024
39 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sec Issues with potential security implications. high priority High priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant