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

Remove all unsafe from codebase, improve parsing speed #8

Merged
merged 6 commits into from
Nov 17, 2021

Conversation

5225225
Copy link
Contributor

@5225225 5225225 commented Nov 10, 2021

Here, the toint_1/2/4 calls require both less unsafe as well as being faster, since they're specialized to the exact width they need to parse.

I ran the benchmarks and got

Before:

parse_imf_fixdate       time:   [121.04 ns 121.10 ns 121.18 ns]
parse_rfc850_date       time:   [116.55 ns 116.67 ns 116.80 ns]
parse_asctime           time:   [112.93 ns 113.04 ns 113.19 ns]
encode_date             time:   [10.981 ns 10.994 ns 11.010 ns]

After:

parse_imf_fixdate       time:   [95.967 ns 96.094 ns 96.255 ns]
                        change: [-20.734% -20.645% -20.539%] (p = 0.00 < 0.05)
                        Performance has improved.

parse_rfc850_date       time:   [87.114 ns 87.320 ns 87.559 ns]
                        change: [-25.294% -25.142% -24.972%] (p = 0.00 < 0.05)
                        Performance has improved.

parse_asctime           time:   [100.90 ns 101.05 ns 101.24 ns]
                        change: [-10.600% -10.280% -9.9340%] (p = 0.00 < 0.05)
                        Performance has improved.

encode_date             time:   [10.990 ns 11.000 ns 11.011 ns]
                        change: [+0.0702% +0.2167% +0.4071%] (p = 0.01 < 0.05)
                        Change within noise threshold.

@5225225 5225225 marked this pull request as ready for review November 10, 2021 18:33
src/date.rs Show resolved Hide resolved
Copy link
Owner

@pyfisch pyfisch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Can you address the comments, fix the formatting and silence clippy? Then its good to go!

src/date.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/date.rs Show resolved Hide resolved
benches/benchmarks.rs Outdated Show resolved Hide resolved
src/date.rs Show resolved Hide resolved
@pyfisch pyfisch merged commit 94d4895 into pyfisch:master Nov 17, 2021
@5225225 5225225 deleted the forbid-unsafe branch November 26, 2021 18:22
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.

2 participants