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

Feature gate multi-threaded sorting #3

Merged
merged 4 commits into from
Mar 25, 2022
Merged

Conversation

nessex
Copy link
Owner

@nessex nessex commented Mar 25, 2022

WHAT

Feature gate multi-threaded sorting, behind a default feature.

This allows you to remove all multi-threading related logic by using:
default-features = false

WHY

Multi-threaded sorting requires importing rayon. If you are only using this library in a single-threaded configuration, this introduces a lot of unnecessary overhead and bloat.

Fixes: #2

@nessex nessex self-assigned this Mar 25, 2022
@nessex
Copy link
Owner Author

nessex commented Mar 25, 2022

Test results

Before

$ cargo bloat --release --crates
    Finished release [optimized] target(s) in 0.00s
    Analyzing target/release/rdst-bloat-test

 File  .text     Size Crate
37.4%  73.1% 275.2KiB std
 6.9%  13.5%  50.9KiB rayon_core
 2.9%   5.6%  21.3KiB rdst
 1.8%   3.5%  13.3KiB rayon
 1.3%   2.5%   9.3KiB crossbeam_epoch
 0.7%   1.4%   5.3KiB [Unknown]
 0.6%   1.3%   4.7KiB crossbeam_channel
 0.5%   0.9%   3.4KiB crossbeam_deque
 0.0%   0.1%     244B rdst_bloat_test
 0.0%   0.0%      32B num_cpus
51.2% 100.0% 376.6KiB .text section size, the file size is 735.8KiB

Note: numbers above are a result of guesswork. They are not 100% correct and never will be.

After

Using default-features = false

$ cargo bloat --release --crates
   Compiling rdst v0.19.2 (/Users/n/dev/github.com/Nessex/rdst)
   Compiling rdst-bloat-test v0.1.0 (/Users/n/dev/github.com/Nessex/rdst-bloat-test)
    Finished release [optimized] target(s) in 0.42s
    Analyzing target/release/rdst-bloat-test

 File  .text     Size Crate
46.5%  94.9% 199.5KiB std
 2.8%   5.7%  11.9KiB rdst
 0.5%   1.1%   2.4KiB [Unknown]
 0.1%   0.1%     240B rdst_bloat_test
49.0% 100.0% 210.2KiB .text section size, the file size is 429.4KiB

Note: numbers above are a result of guesswork. They are not 100% correct and never will be.

@nessex nessex mentioned this pull request Mar 25, 2022
@nessex nessex changed the title WIP: Feature gate multi-threaded sorting Feature gate multi-threaded sorting Mar 25, 2022
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.

Make rayon optional
1 participant