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

Optimize block-less overloads of BitArray#fill #11450

Merged
merged 3 commits into from
Jan 30, 2022

Conversation

HertzDevil
Copy link
Contributor

Now that even more overloads of Indexable::Mutable#fill are available, this PR uses Slice#fill, i.e. memset, to speed up the block-less overloads of BitArray#fill.

Improvements over 1000x were observed on very large BitArrays.

@oprypin oprypin self-requested a review December 4, 2021 10:12
@HertzDevil
Copy link
Contributor Author

Here is a real-world example, Advent of Code 2015, day 6, part one: (spoilers alert) https://gist.github.com/HertzDevil/dcdab4919973a74ff6dc3fee1cad3d1d

old  26.72  ( 37.42ms) (± 3.27%)  276kB/op  10.26× slower
new 274.27  (  3.65ms) (± 4.39%)  276kB/op        fastest

src/bit_array.cr Show resolved Hide resolved
src/bit_array.cr Outdated Show resolved Hide resolved
src/bit_array.cr Outdated Show resolved Hide resolved
@beta-ziliani beta-ziliani added this to the 1.4.0 milestone Jan 28, 2022
@straight-shoota straight-shoota merged commit 7f7ea69 into crystal-lang:master Jan 30, 2022
@HertzDevil HertzDevil deleted the perf/bitarray-fill branch February 1, 2022 02:56
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.

4 participants